Package com.alibaba.wasp.plan.action

Examples of com.alibaba.wasp.plan.action.UpdateAction


    String tableName = "test";
    String primary = "1234";
    String familyName = "info";
    String columnName = "col";
    String value = "8899";
    UpdateAction action = new UpdateAction(tableName, Bytes.toBytes(primary));
    action.addEntityColumn(tableName, familyName, columnName, DataType.STRING,
        Bytes.toBytes(value));
    MessageProto message = ProtobufUtil.convertUpdateAction(action);
    action = (UpdateAction) ProtobufUtil.convertWriteAction(message);
    Assert.assertTrue(tableName.equals(action.getFTableName()));
    Assert.assertTrue(primary.equals(Bytes.toString(action.getCombinedPrimaryKey())));
    Assert.assertTrue(action.getColumns().get(0).getFamilyName()
        .equals(familyName)
        && action.getColumns().get(0).getColumnName().equals(columnName)
        && Bytes.toString(action.getColumns().get(0).getValue()).equals(value));
  }
View Full Code Here


      throw new IOException("Not match primary key.");
    }

    byte[] primayKey = RowBuilder.build().genRowkey(primaryKeyPairs);

    UpdateAction action = new UpdateAction(fTableName, primayKey);
    // Parse Update Item
    List<SQLUpdateSetItem> updateItems = sqlUpdateStatement.getItems();
    for (SQLUpdateSetItem updateItem : updateItems) {
      String columnName = parseColumn(updateItem.getColumn());
      // check this FTable has the column and not pk
      metaEventOperation.checkFieldNotInPrimaryKeys(table, columnName);
      Field field = table.getColumn(columnName);
      // Check the input is the same as DataType
      checkType(field, updateItem.getValue());
      byte[] value = convert(field, updateItem.getValue());
      String familyName = metaEventOperation.getColumnFamily(fTableName,
          columnName);
      action.addEntityColumn(fTableName, familyName, columnName,
          field.getType(), value);
    }
    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);
    }
    action.setSessionId(context.getSessionId());
    List<UpdateAction> actions = new ArrayList<UpdateAction>();
    actions.add(action);
    UpdatePlan plan = new UpdatePlan(actions);
    context.setPlan(plan);
    LOG.debug("UpdatePlan " + plan);
View Full Code Here

      throws ServiceException {
    List<ClientProtos.WriteResultProto> writeResultProtos = new ArrayList<ClientProtos.WriteResultProto>();
    List<UpdateAction> updateActions = plan.getActions();
    // if actions > 1. will commit by 2pc
    if (updateActions.size() == 1) {
      UpdateAction action = updateActions.get(0);
      EntityGroupInfo entityGroupInfo = action.getEntityGroupLocation()
          .getEntityGroupInfo();
      ServerName serverName = new ServerName(action.getEntityGroupLocation()
          .getHostname(), action.getEntityGroupLocation().getPort(),
          ServerName.NON_STARTCODE);
      try {
        if (workingOnLocalServer(server, serverName)) {
          ClientProtos.UpdateResponse response = server.update(
              entityGroupInfo.getEntityGroupName(), action);
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.plan.action.UpdateAction

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.