Package com.alibaba.wasp

Examples of com.alibaba.wasp.EntityGroupLocation


    return transactionPlan;
  }

  private static TransactionAction createTransactionAction(String parentTable, List<DMLAction> dmlActions) throws TransactionParseException {
    TransactionAction transactionAction = new TransactionAction(parentTable, dmlActions);
    EntityGroupLocation entityGroupLocation = null;
    for (DMLAction dmlAction : dmlActions) {
      if(entityGroupLocation == null) {
        entityGroupLocation = dmlAction.getEntityGroupLocation();
      } else {
        if(entityGroupLocation.compareTo(dmlAction.getEntityGroupLocation()) != 0) {
          throw new TransactionParseException("child table row must be the same entityGoup with parent row. it means value of egk row must be same");
        }
      }
    }
    transactionAction.setEntityGroupLocation(entityGroupLocation);
View Full Code Here


    }

    if (context.isGenWholePlan()) {
      for (InsertAction insertAction : actions) {
        // Get entityGroupLocation according to entity group key
        EntityGroupLocation entityGroupLocation = this.connection
            .locateEntityGroup(Bytes.toBytes(table.getTableName()),
                insertAction.getValueOfEntityGroupKey());
        insertAction.setEntityGroupLocation(entityGroupLocation);
      }
    }
View Full Code Here

    DeleteAction action = new DeleteAction(wtableName, primayKey);
    if (context.isGenWholePlan()) {
      Condition entityGroupKeyCondition = ParserUtils.getCondition(table
          .getEntityGroupKey().getName(), eqConditions);
      // Get entityGroupLocation according to entity group key
      EntityGroupLocation entityGroupLocation = this.connection
          .locateEntityGroup(Bytes.toBytes(table.getTableName()), DruidParser
              .convert(table.getColumn(entityGroupKeyCondition.getFieldName()),
                  entityGroupKeyCondition.getValue()));
      action.setEntityGroupLocation(entityGroupLocation);
    }
View Full Code Here

    }
    if (context.isGenWholePlan()) {
      Condition entityGroupKeyCondition = ParserUtils.getCondition(table
          .getEntityGroupKey().getName(), conditions);
      // Get entityGroupLocation according to entity group key
      EntityGroupLocation entityGroupLocation = this.connection
          .locateEntityGroup(Bytes.toBytes(table.getTableName()), DruidParser
              .convert(table.getColumn(entityGroupKeyCondition.getFieldName()),
                  entityGroupKeyCondition.getValue()));
      action.setEntityGroupLocation(entityGroupLocation);
    }
View Full Code Here

        throws ServiceException {
      try {
        queryResultProtos.clear();

        GetAction action = plan.getGetAction();
        EntityGroupLocation entityGroupLocation = action
            .getEntityGroupLocation();
        EntityGroupInfo entityGroupInfo = entityGroupLocation
            .getEntityGroupInfo();
        ServerName serverName = new ServerName(
            entityGroupLocation.getHostname(), entityGroupLocation.getPort(),
            ServerName.NON_STARTCODE);
        ClientProtos.GetResponse response = null;
        // local
        boolean localGet = workingOnLocalServer(server, serverName);
        if (localGet) {// if the target entityGroup's server is current
View Full Code Here

          primaryKey, this.buildEntityColumnsForGet(table, metaEventOperation,
              selectItem));
      ((GetAction)action).setForUpdate(queryInfo.isForUpdate());
      if (context.isGenWholePlan()) {
        // get entityGroupLocation according to entity group key.
        EntityGroupLocation entityGroupLocation = this.connection
            .locateEntityGroup(Bytes.toBytes(table.getTableName()), DruidParser
                .convert(
                    table.getColumn(entityGroupKeyCondition.getFieldName()),
                    entityGroupKeyCondition.getValue()));
        action.setEntityGroupLocation(entityGroupLocation);
      }
      qp = new LocalQueryPlan((GetAction) action);
      LOG.debug(QueryInfo.QueryType.GET + "  "
          + Bytes.toStringBinary(primaryKey) + " from " + table.getTableName());
    } else if (queryInfo.getType() == QueryInfo.QueryType.SCAN) {
      Index index = metaEventOperation.checkAndGetIndex(table,
          queryInfo.getAllConditionFieldName());

      if (index == null) {
        throw new UnsupportedException("Don't get a Index!");
      }

      boolean isJustUseIndex = index.getIndexKeys().size() >= queryInfo.getAllConditionFieldName().size();
      Pair<byte[], byte[]> startKeyAndEndKey = metaEventOperation.getStartkeyAndEndkey(index, queryInfo);

      Pair<List<ColumnStruct>, List<ColumnStruct>> columnActionPair = this
          .buildEntityColumnsForScan(table, index, metaEventOperation,
              selectItem);
      List<ColumnStruct> selectEntityColumns = columnActionPair.getFirst();
      List<ColumnStruct> selectStoringColumns = columnActionPair.getSecond();
      List<ColumnStruct> conditionNotInIndex = isJustUseIndex ? Collections.<ColumnStruct>emptyList()
          : buildColumnsNotInIndex(table, index, queryInfo);

      // instance scan action.
      action = new ScanAction(context.getReadModel(),
          StorageTableNameBuilder.buildIndexTableName(index),
          table.getTableName(), startKeyAndEndKey.getFirst(),
          startKeyAndEndKey.getSecond(), selectEntityColumns);
      ((ScanAction) action).setStoringColumns(selectStoringColumns);
      ((ScanAction) action).setLimit(limit);
      ((ScanAction) action).setNotIndexConditionColumns(conditionNotInIndex);

      if (entityGroupKeyCondition != null
          && entityGroupKeyCondition.getType() == ConditionType.EQUAL) {
        if (context.isGenWholePlan()) {
          EntityGroupLocation entityGroupLocation = this.connection
              .locateEntityGroup(Bytes.toBytes(table.getTableName()),
                  DruidParser.convert(
                      table.getColumn(entityGroupKeyCondition.getFieldName()),
                      entityGroupKeyCondition.getValue()));
          action.setEntityGroupLocation(entityGroupLocation);
View Full Code Here

    public Pair<List<ClientProtos.QueryResultProto>, List<ClientProtos.StringDataTypePair>> execute()
        throws ServiceException {
      try {
        queryResultProtos.clear();
        ScanAction action = plan.getScanAction();
        EntityGroupLocation entityGroupLocation = action
            .getEntityGroupLocation();
        EntityGroupInfo entityGroupInfo = entityGroupLocation
            .getEntityGroupInfo();
        serverName = new ServerName(entityGroupLocation.getHostname(),
            entityGroupLocation.getPort(), ServerName.NON_STARTCODE);
        ClientProtos.ScanResponse response = null;
        // local
        localScan = workingOnLocalServer(server, serverName);
        do {
          if (localScan) {// if the target entityGroup's server is current
View Full Code Here

              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,
            sn.getHostname(), sn.getPort());
        return egLoc;
      }
    } catch (IOException e) {
      throw new MetaException(e);
View Full Code Here

        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,
            sn.getHostname(), sn.getPort());
        egLocations.add(egLoc);
        // Returning true means "keep scanning"
        return true;
      }
View Full Code Here

            || t instanceof ConnectException
            || t instanceof RetriesExhaustedException) {
          // if thrown these exceptions, we clear all the cache entries that
          // map to that slow/dead server; otherwise, let cache miss and ask
          // .FMETA. again to find the new location
          EntityGroupLocation egl = location;
          if (egl != null) {
            getConnection().clearCaches(egl.getHostnamePort());
          }
        }

        if(t instanceof RuntimeException) {
          throw new RuntimeException(t);
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.EntityGroupLocation

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.