Package com.alibaba.wasp

Examples of com.alibaba.wasp.EntityGroupInfo


      checkInitialized();
      if (type != EntityGroupSpecifierType.ENTITYGROUP_NAME) {
        LOG.warn("assignEntityGroup specifier type: expected: "
            + EntityGroupSpecifierType.ENTITYGROUP_NAME + " actual: " + type);
      }
      EntityGroupInfo entityGroupInfo = assignmentManager
          .getEntityGroupStates().getEntityGroupInfo(entityGroupName);
      if (entityGroupInfo == null)
        throw new UnknownEntityGroupException(Bytes.toString(entityGroupName));
      assignmentManager.assign(entityGroupInfo, true, true);
      return aegr;
View Full Code Here


      }
      Pair<EntityGroupInfo, ServerName> pair = FMetaReader
          .getEntityGroupAndLocation(this.conf, entityGroupName);
      if (pair == null)
        throw new UnknownEntityGroupException(Bytes.toString(entityGroupName));
      EntityGroupInfo egInfo = pair.getFirst();
      if (force) {
        this.assignmentManager.entityGroupOffline(egInfo);
        assignEntityGroup(egInfo);
      } else {
        this.assignmentManager.unassign(egInfo, force);
View Full Code Here

      Pair<EntityGroupInfo, ServerName> pair = FMetaReader
          .getEntityGroupAndLocation(this.conf, entityGroupName);
      if (pair == null)
        throw new UnknownEntityGroupException(
            Bytes.toStringBinary(entityGroupName));
      EntityGroupInfo egInfo = pair.getFirst();
      this.assignmentManager.entityGroupOffline(egInfo);
    } catch (IOException ioe) {
      throw new ServiceException(ioe);
    }
    return OfflineEntityGroupResponse.newBuilder().build();
View Full Code Here

  private EntityGroupInfo[] getEntityGroupInfos(FTable desc, byte[][] splitKeys) {
    if (desc.getTableType() == TableType.ROOT) {
      EntityGroupInfo[] egInfos = null;
      byte[] tableName = Bytes.toBytes(desc.getTableName());
      if (splitKeys == null || splitKeys.length == 0) {
        egInfos = new EntityGroupInfo[] { new EntityGroupInfo(tableName, null,
            null) };
      } else {
        int numEntityGroups = splitKeys.length + 1;
        egInfos = new EntityGroupInfo[numEntityGroups];
        byte[] startKey = null;
        byte[] endKey = null;
        for (int i = 0; i < numEntityGroups; i++) {
          endKey = (i == splitKeys.length) ? null : splitKeys[i];
          egInfos[i] = new EntityGroupInfo(tableName, startKey, endKey);
          startKey = endKey;
        }
      }
      return egInfos;
    } else if (desc.getTableType() == TableType.CHILD) {
View Full Code Here

    final AtomicInteger actualEgCount = new AtomicInteger(0);
    MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
      @Override
      public boolean processRow(org.apache.hadoop.hbase.client.Result rowResult)
          throws IOException {
        EntityGroupInfo info = EntityGroupInfo.getEntityGroupInfo(rowResult);
        if (info == null) {
          LOG.warn("No serialized EntityGroupInfo in " + rowResult);
          return true;
        }
        if (!(Bytes.equals(info.getTableName(), tableNameBytes))) {
          return false;
        }
        ServerName serverName = EntityGroupInfo.getServerName(rowResult);
        // Make sure that entityGroups are assigned to server
        if (!(info.isOffline() || info.isSplit()) && serverName != null
            && serverName.getHostAndPort() != null) {
          actualEgCount.incrementAndGet();
        }
        return true;
      }
View Full Code Here

        final String encodedName = Bytes.toString(tableNameOrEntityGroupName);
        MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
          @Override
          public boolean processRow(org.apache.hadoop.hbase.client.Result data)
              throws IOException {
            EntityGroupInfo info = EntityGroupInfo.getEntityGroupInfo(data);
            if (info == null) {
              LOG.warn("No serialized EntityGroupInfo in " + data);
              return true;
            }
            if (!encodedName.equals(info.getEncodedName())) {
              return true;
            }
            ServerName sn = EntityGroupInfo.getServerName(data);
            result.set(new Pair<EntityGroupInfo, ServerName>(info, sn));
            return false; // found the entityGroup, stop
View Full Code Here

    LinkedHashMap<String, Field> finalFields = new LinkedHashMap<String, Field>();
    for (Field field : fields) {
      finalFields.put(field.getName(), field);
    }
    table.setColumns(finalFields);
    EntityGroupInfo info = new EntityGroupInfo(Bytes.toBytes(table
        .getTableName()), startKey, stopKey, false);

    if (FMetaReader.exists(TEST_UTIL.getConfiguration(), info)) {
      throw new IOException("All ready has a entityGroupInfo "
          + info.getEntityGroupNameAsString());
    }
    return EntityGroup.openEntityGroup(info, table, conf, TEST_UTIL
        .getWaspCluster().getFServer(0), null);
  }
View Full Code Here

      CreateTablePlan createPlan = (CreateTablePlan) plan;
      table = createPlan.getTable();
      TableSchemaCacheReader.getService(conf).createTable(table);
      reader.addSchema(table.getTableName(), table);
    }
    EntityGroupInfo egi = new EntityGroupInfo(table.getTableName(), null, null);
    MockFServerServices service = new MockFServerServices();
    eg = new EntityGroup(conf, egi, table, service);
    NullStorageServices storageServices = new NullStorageServices();
    eg.setStorageServices(storageServices);
    eg.initialize();
View Full Code Here

    // Create table then get the single entityGroup for our new table.
    FTable t = TESTING_UTIL.createTable(tableName);

    List<EntityGroup> entityGroups = cluster.getEntityGroups(tableName);
    EntityGroupInfo egi = getAndCheckSingleTableEntityGroup(entityGroups);

    int tableEntityGroupIndex = getTableEntityGroupIndex(admin, egi);

    // Turn off balancer so it doesn't cut in and mess up our placements.
    admin.setBalancerRunning(false, true);
    try {
      // Add a bit of load up into the table so splittable.
      TESTING_UTIL.loadTable(t);
      // Get entityGroup pre-split.
      FServer server = cluster.getFServer(tableEntityGroupIndex);
      printOutEntityGroups(server, "Initial entityGroups: ");
      int entityGroupCount = ProtobufUtil.getOnlineEntityGroups(server).size();
      // Now, before we split, set special flag in master, a flag that has
      // it FAIL the processing of split.
      SplitEntityGroupHandler.TEST_SKIP = true;
      // Now try splitting and it should work.
      split(egi, "1", server, entityGroupCount);
      // Get daughters
      List<EntityGroup> daughters = checkAndGetDaughters(tableName);
      // Assert the ephemeral node is up in zk.
      String path = ZKAssign.getNodeName(zkw, egi.getEncodedName());
      Stat stats = zkw.getRecoverableZooKeeper().exists(path, false);
      LOG.info("EPHEMERAL NODE BEFORE SERVER ABORT, path=" + path + ", stats="
          + stats);
      EntityGroupTransaction rtd = EntityGroupTransaction.parseFrom(ZKAssign
          .getData(zkw, egi.getEncodedName()));
      // State could be SPLIT or SPLITTING.
      assertTrue(rtd.getEventType().equals(
          EventHandler.EventType.FSERVER_ZK_ENTITYGROUP_SPLIT)
          || rtd.getEventType().equals(
              EventHandler.EventType.FSERVER_ZK_ENTITYGROUP_SPLITTING));
View Full Code Here

    // Create table then get the single entityGroup for our new table.
    FTable t = TESTING_UTIL.createTable(tableName);
    // TESTING_UTIL.waitTableEnabled(tableName, 5000);
    List<EntityGroup> entityGroups = cluster.getEntityGroups(tableName);
    EntityGroupInfo egi = getAndCheckSingleTableEntityGroup(entityGroups);

    int tableEntityGroupIndex = getTableEntityGroupIndex(admin, egi);

    try {
      // Add a bit of load up into the table so splittable.
      TESTING_UTIL.loadTable(t);
      // Get entityGroup pre-split.
      FServer server = cluster.getFServer(tableEntityGroupIndex);
      printOutEntityGroups(server, "Initial entityGroups: ");
      int entityGroupCount = server.getOnlineEntityGroups().size();
      // Insert into zk a blocking znode, a znode of same name as entityGroup
      // so it gets in way of our splitting.

      ZooKeeperWatcher zkw = WaspTestingUtility
          .getZooKeeperWatcher(TESTING_UTIL);
      ZKAssign.createNodeClosing(zkw, egi, new ServerName("any.old.server",
          1234, -1));
      // Now try splitting.... should fail. And each should successfully
      // rollback.
      admin.split(egi.getEntityGroupNameAsString(), "3");
      admin.split(egi.getEntityGroupNameAsString(), "2");
      admin.split(egi.getEntityGroupNameAsString(), "1");
      // Wait around a while and assert count of entityGroups remains constant.
      for (int i = 0; i < 10; i++) {
        Thread.sleep(100);
        assertEquals(entityGroupCount, server.getOnlineEntityGroups().size());
      }
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.EntityGroupInfo

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.