Package com.alibaba.wasp.client

Examples of com.alibaba.wasp.client.WaspAdmin


    assertTrue(stat.getUpdateCount() == -1);
    count = stat.executeUpdate("DELETE FROM TEST WHERE ID=1");
    assertFalse(stat.getMoreResults());
    assertTrue(stat.getUpdateCount() == -1);

    WaspAdmin admin = new WaspAdmin(TEST_UTIL.getConfiguration());
    admin.disableTable("TEST");
    stat.execute("DROP TABLE TEST");
    admin.waitTableNotLocked("TEST".getBytes());
    stat.executeUpdate("DROP TABLE IF EXISTS TEST");

    assertTrue(stat.getWarnings() == null);
    stat.clearWarnings();
    assertTrue(stat.getWarnings() == null);
    assertTrue(conn == stat.getConnection());

    admin.close();
    stat.close();
  }
View Full Code Here


      throws IOException {
    FMaster master = (FMaster) getServletContext().getAttribute(FMaster.MASTER);
    assert master != null : "No Master in context!";

    Configuration conf = master.getConfiguration();
    WaspAdmin admin = new WaspAdmin(conf);

    List<ServerName> servers = master.getFServerManager()
        .getOnlineServersList();
    Set<ServerName> deadServers = master.getFServerManager().getDeadServers();
View Full Code Here

        "wasp.ipc.server.blacklist.enable", true);
    TESTING_UTIL.getConfiguration().setBoolean("wasp.testing.nocluster", false);
    TESTING_UTIL.startMiniCluster(NB_SERVERS);
    TableSchemaCacheReader.getInstance(TESTING_UTIL.getConfiguration())
        .clearCache();
    admin = new WaspAdmin(TESTING_UTIL.getConfiguration());
    cluster = TESTING_UTIL.getMiniWaspCluster();
    zkw = WaspTestingUtility.getZooKeeperWatcher(TESTING_UTIL);
  }
View Full Code Here

              EventHandler.EventType.FSERVER_ZK_ENTITYGROUP_SPLITTING));

      // abort and wait for new master.
      FMaster master = abortAndWaitForMaster();

      admin = new WaspAdmin(TESTING_UTIL.getConfiguration());

      // update the egi to be offlined and splitted.
      egi.setOffline(true);
      egi.setSplit(true);
      EntityGroupPlan egPlan = master.getAssignmentManager()
View Full Code Here

      throws Exception {
    final byte[] tableName = Bytes
        .toBytes("testTableExistsIfTheSpecifiedTableEntityGroupIsSplitParent");
    FServer fServer = null;
    List<EntityGroup> entityGroups = null;
    WaspAdmin admin = new WaspAdmin(TESTING_UTIL.getConfiguration());
    try {
      // Create table then get the single entityGroup for our new table.
      FTable t = TESTING_UTIL.createTable(tableName);
      TESTING_UTIL.waitTableEnabled(tableName, 5000);
      entityGroups = cluster.getEntityGroups(tableName);
      int fserverIndex = cluster.getServerWith(entityGroups.get(0)
          .getEntityGroupName());
      fServer = cluster.getFServer(fserverIndex);
      insertData(tableName, admin, t);
      // Turn off balancer so it doesn't cut in and mess up our placements.
      boolean tableExists = FMetaReader.tableExists(
          TESTING_UTIL.getConfiguration(), Bytes.toString(tableName));
      assertEquals("The specified table should present.", true, tableExists);
      SplitTransaction st = new SplitTransaction(entityGroups.get(0),
          Bytes.toBytes("row2"), TESTING_UTIL.getConfiguration());
      try {
        st.prepare();
        st.createDaughters(fServer, fServer);
      } catch (IOException e) {

      }
      tableExists = FMetaReader.tableExists(TESTING_UTIL.getConfiguration(),
          Bytes.toString(tableName));
      assertEquals("The specified table should present.", true, tableExists);
    } finally {
      admin.close();
    }
  }
View Full Code Here

   */
  public static void main(String[] args) throws IOException {
    Configuration conf = WaspConfiguration.create();
    LocalWaspCluster cluster = new LocalWaspCluster(conf);
    cluster.startup();
    WaspAdmin admin = new WaspAdmin(conf);
    FTable table = new FTable();
    table.setTableName(cluster.getClass().getName());
    admin.createTable(table);
    cluster.shutdown();
  }
View Full Code Here


  @Test
  public void testSplitOrMoveAffectClient() throws SQLException, IOException, InterruptedException {

    WaspAdmin admin = TEST_UTIL.getWaspAdmin();

    String createTableSql = "CREATE TABLE user123{REQUIRED INT64 user_id;" +
        "REQUIRED INT64 photo_id;}" +
        "PRIMARY KEY(user_id)," +
        "ENTITY GROUP ROOT," +
        "ENTITY GROUP KEY(user_id)," +
        "PARTITION BY RANGE('A', 'Z', 4);";
    stat = conn.createStatement();
    stat.executeUpdate(createTableSql);

    admin.waitTableNotLocked("user123");
    admin.disableTable("user123");
    admin.waitTableDisabled("user123", 3000);
    stat.executeUpdate("create index test_index on " + "user123" + "(photo_id);");
    admin.waitTableNotLocked("user123");
    admin.enableTable("user123");
    admin.waitTableEnabled("user123", 3000);
    stat.execute("INSERT INTO user123 (user_id, photo_id) VALUES (1, 1)");
    stat.execute("INSERT INTO user123 (user_id, photo_id) VALUES (2, 2)");
    stat.execute("INSERT INTO user123 (user_id, photo_id) VALUES (3, 3)");
    stat.execute("INSERT INTO user123 (user_id, photo_id) VALUES (4, 4)");

    List<EntityGroupInfo> egis =  admin.getTableEntityGroups(Bytes.toBytes("user123"));

    admin.split(egis.get(0).getEntityGroupName(), Bytes.toBytes("H"));


    stat.execute("INSERT INTO user123 (user_id, photo_id) VALUES (5, 5)");

    ResultSet rs;
    rs = stat.executeQuery("select * from user123 where photo_id=5");
    assertTrue(rs.next());
    assertTrue(rs.getLong("user_id") == 5);

    egis =  admin.getTableEntityGroups(Bytes.toBytes("user123"));

    ClusterStatus status = admin.getClusterStatus();
    List<ServerName> serverNames = new ArrayList<ServerName>(status.getServers());

    egis = admin.getOnlineEntityGroups(serverNames.get(0));

    admin.move(egis.get(0).getEncodedNameAsBytes(), Bytes.toBytes(serverNames.get(1).getServerName()));

    stat.execute("INSERT INTO user123 (user_id, photo_id) VALUES (6, 6)");
    rs = stat.executeQuery("select * from user123 where photo_id=6");
    assertTrue(rs.next());
    assertTrue(rs.getLong("user_id") == 6);
View Full Code Here

   * @return The WaspAdmin instance.
   * @throws java.io.IOException
   */
  public synchronized WaspAdmin getWaspAdmin() throws IOException {
    if (waspAdmin == null) {
      waspAdmin = new WaspAdmin(getConfiguration());
    }
    return waspAdmin;
  }
View Full Code Here

    }
    return 0;
  }

  private int stopMaster() {
    WaspAdmin adm = null;
    try {
      Configuration conf = getConf();
      // Don't try more than once
      conf.setInt("wasp.client.retries.number", 1);
      adm = new WaspAdmin(getConf());
    } catch (MasterNotRunningException e) {
      LOG.error("Master not running");
      return -1;
    } catch (ZooKeeperConnectionException e) {
      LOG.error("ZooKeeper not available");
      return -1;
    }
    try {
      adm.shutdown();
    } catch (Throwable t) {
      LOG.error("Failed to stop master", t);
      return -1;
    } finally {
      if (adm != null) {
        try {
          adm.close();
        } catch (IOException e) {
          LOG.error("Failed to close admin.");
          return -1;
        }
      }
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.client.WaspAdmin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.