Package com.alibaba.wasp

Examples of com.alibaba.wasp.EntityGroupInfo


      return fmetaTable;
    }

    @Override
    public boolean processRow(Result rowResult) throws IOException {
      EntityGroupInfo info = getEntityGroupInfo(rowResult);
      if (info == null) {
        return true;
      }

      if (daughterEntityGroups.remove(info.getEntityGroupName())) {
        return true; // we have already processed this row
      }

      if (info.isSplitParent()) {
        /*
         * we have found a parent entityGroup which was split. We have to ensure
         * that it's daughters are seen by this scanner as well, so we block
         * until they are added to the META table. Even though we are waiting
         * for META entries, ACID semantics in HBase indicates that this scanner
         * might not see the new rows. So we manually query the daughter rows
         */
        PairOfSameType<EntityGroupInfo> daughters = EntityGroupInfo
            .getDaughterEntityGroups(rowResult);
        EntityGroupInfo splitA = daughters.getFirst();
        EntityGroupInfo splitB = daughters.getSecond();

        HTable fmetaTable = getFMetaTable();
        long start = System.currentTimeMillis();
        Result resultA = getEntityGroupResultBlocking(fmetaTable,
            blockingTimeout, splitA.getEntityGroupName());
        if (resultA != null) {
          processRow(resultA);
          daughterEntityGroups.add(splitA.getEntityGroupName());
        } else {
          throw new EnityGroupOfflineException("Split daughter entityGroup "
              + splitA.getEntityGroupNameAsString()
              + " cannot be found in META.");
        }
        long rem = blockingTimeout - (System.currentTimeMillis() - start);

        Result resultB = getEntityGroupResultBlocking(fmetaTable, rem,
            splitB.getEntityGroupName());
        if (resultB != null) {
          processRow(resultB);
          daughterEntityGroups.add(splitB.getEntityGroupName());
        } else {
          throw new EnityGroupOfflineException("Split daughter entityGroup "
              + splitB.getEntityGroupNameAsString()
              + " cannot be found in META.");
        }
      }

      return processRowInternal(rowResult);
View Full Code Here


      }
      long start = System.currentTimeMillis();
      while (System.currentTimeMillis() - start < timeout) {
        Get get = new Get(entityGroupName);
        Result result = fmetaTable.get(get);
        EntityGroupInfo entityGroupInfo = getEntityGroupInfo(result);
        if (entityGroupInfo != null) {
          return result;
        }
        try {
          Thread.sleep(10);
View Full Code Here

      this.tableName = tableName;
    }

    @Override
    public final boolean processRow(Result rowResult) throws IOException {
      EntityGroupInfo entityGroupInfo = getEntityGroupInfo(rowResult);
      if (entityGroupInfo == null) {
        return true;
      }
      if (!(Bytes.equals(entityGroupInfo.getTableName(), tableName))) {
        return false;
      }
      return super.processRow(rowResult);
    }
View Full Code Here

          @Override
          public boolean visit(Result r) throws IOException {
            if (r == null || r.isEmpty()) {
              return true;
            }
            EntityGroupInfo info = EntityGroupInfo.getEntityGroupInfo(r);
            if (info == null) {
              return true; // Keep scanning
            }
            if (info.isOffline()) {
              return true; // Keep scanning
            }
            if (info.isSplit()) {
              return true; // Keep scanning
            }
            if (LOG.isDebugEnabled()) {
              LOG.debug("EntityGroupInfo : " + info.toString());
            }
            if (Bytes.equals(info.getTableName(), rootTableName)) {
              // find it, so end search
              ServerName sn = ServerName.getServerName(r);
              EntityGroupLocation egLoc = new EntityGroupLocation(info,
                  sn.getHostname(), sn.getPort());
              results.add(egLoc);
              return false;
            }
            return true;
          }
        };
        // Run full scan of _FMETA_ catalog table passing in our custom visitor
        fullScan(visitor, rootTableName, null);
        return results.size() == 0 ? null : results.get(0);
      } else {
        EntityGroupInfo info = EntityGroupInfo.getEntityGroupInfo(r);
        if (info == null) {
          throw new TableNotFoundException(Bytes.toString(tableName));
        }
        ServerName sn = ServerName.getServerName(r);
        EntityGroupLocation egLoc = new EntityGroupLocation(info,
View Full Code Here

      public boolean visit(Result r) throws IOException {
        if (r == null || r.isEmpty()) {
          return true;
        }
        byte[] value = r.getValue(FConstants.CATALOG_FAMILY, FConstants.EGINFO);
        EntityGroupInfo eginfo = EntityGroupInfo.parseFromOrNull(value);
        if (eginfo == null) {
          return true;
        }
        if (!Bytes.equals(eginfo.getTableName(), tableName)) {
          // this is another table, we can exit search.
          return false;
        }
        ServerName sn = ServerName.getServerName(r);
        EntityGroupLocation egLoc = new EntityGroupLocation(eginfo,
View Full Code Here

    final List<Pair<EntityGroupInfo, ServerName>> entityGroupInfos = new ArrayList<Pair<EntityGroupInfo, ServerName>>();
    FMetaVisitor visitor = new FMetaVisitor() {
      @Override
      public boolean visit(Result r) throws IOException {
        byte[] value = r.getValue(FConstants.CATALOG_FAMILY, FConstants.EGINFO);
        EntityGroupInfo egi = EntityGroupInfo.parseFromOrNull(value);
        if (egi == null) {
          LOG.warn("No serialized EntityGroupInfo in " + r);
          return true; // Keep scanning
        }
        if (excludeOfflinedSplitParents && egi.isSplitParent()) {
          return true; // Keep scanning
        }
        if (!Bytes.equals(egi.getTableName(), tableName)) {
          // this is another table, we can exit search.
          return false;
        }
        ServerName sn = ServerName.getServerName(r);
        entityGroupInfos.add(new Pair<EntityGroupInfo, ServerName>(egi, sn));
View Full Code Here

    return entityGroupInfos;
  }

  public void offlineParentInMeta(EntityGroupInfo parent,
      final EntityGroupInfo a, final EntityGroupInfo b) throws MetaException {
    EntityGroupInfo copyOfParent = new EntityGroupInfo(parent);
    copyOfParent.setOffline(true);
    copyOfParent.setSplit(true);
    addEntityGroupToMeta(copyOfParent, a, b);
    LOG.info("Offlined parent entityGroup "
        + parent.getEntityGroupNameAsString() + " in META");
  }
View Full Code Here

    final AtomicBoolean available = new AtomicBoolean(true);
    final AtomicInteger entityGroupCount = new AtomicInteger(0);
    FMetaScanner.MetaScannerVisitor visitor = new FMetaScanner.MetaScannerVisitorBase() {
      @Override
      public boolean processRow(Result row) throws IOException {
        EntityGroupInfo info = FMetaScanner.getEntityGroupInfo(row);
        if (info != null) {
          if (Bytes.equals(tableName, info.getTableName())) {
            ServerName sn = ServerName.getServerName(row);
            if (sn == null) {
              available.set(false);
              return false;
            }
View Full Code Here

      }
      setAllEntityGroupServersOffline(noFSERVERAvailable);
    }

    private void actOnTimeOut(EntityGroupState entityGroupState) {
      EntityGroupInfo entityGroupInfo = entityGroupState.getEntityGroup();
      LOG.info("EntityGroups in transition timed out:  " + entityGroupState);
      // Expired! Do a retry.
      switch (entityGroupState.getState()) {
      case CLOSED:
        LOG.info("EntityGroup " + entityGroupInfo.getEncodedName()
            + " has been CLOSED for too long, waiting on queued "
            + "ClosedEntityGroupHandler to run or server shutdown");
        // Update our timestamp.
        entityGroupState.updateTimestampToNow();
        break;
      case OFFLINE:
        LOG.info("EntityGroup has been OFFLINE for too long, " + "reassigning "
            + entityGroupInfo.getEntityGroupNameAsString()
            + " to a random server");
        invokeAssign(entityGroupInfo);
        break;
      case PENDING_OPEN:
        LOG.info("EntityGroup has been PENDING_OPEN for too "
            + "long, reassigning entityGroup="
            + entityGroupInfo.getEntityGroupNameAsString());
        invokeAssign(entityGroupInfo);
        break;
      case OPENING:
        processOpeningState(entityGroupInfo);
        break;
      case OPEN:
        LOG.error("EntityGroup has been OPEN for too long, "
            + "we don't know where entityGroup was opened so can't do anything");
        entityGroupState.updateTimestampToNow();
        break;

      case PENDING_CLOSE:
        LOG.info("EntityGroup has been PENDING_CLOSE for too "
            + "long, running forced unassign again on entityGroup="
            + entityGroupInfo.getEntityGroupNameAsString());
        invokeUnassign(entityGroupInfo);
        break;
      case CLOSING:
        LOG.info("EntityGroup has been CLOSING for too "
            + "long, this should eventually complete or the server will "
View Full Code Here

    MetaScannerVisitorBase visitor = new MetaScannerVisitorBase() {
      @Override
      public boolean processRow(Result rowResult) throws IOException {
        byte[] value = rowResult.getValue(FConstants.CATALOG_FAMILY,
            FConstants.EGINFO);
        EntityGroupInfo eginfo = EntityGroupInfo.parseFromOrNull(value);
        if (eginfo != null) {
          if (Bytes.equals(eginfo.getTableName(), rootTableName)) {
            value = rowResult.getValue(FConstants.CATALOG_FAMILY,
                FConstants.EGLOCATION);
            if (value == null) {
              available.set(false);
              return false;
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.