Package com.alibaba.wasp

Examples of com.alibaba.wasp.ClientConcernedException


            pair = fClient.execute(sqls, session.getSessionId());
          }
        }
      } catch (IOException ioe) {
        if (ioe instanceof ClientConcernedException) {
          ClientConcernedException exception = (ClientConcernedException) ioe;
          throw new SQLException(JdbcException.get(exception.getErrorCode(),
              ioe, ioe.getMessage()));
        }

        log.error("FClinet execute sql error", ioe);
        throw new RuntimeException(ioe);
      }

      // if the query result is null
      if (pair == null) {
        return;
      }

      Pair<Boolean, List<ExecuteResult>> resultPair = pair.getSecond();
      if (resultPair == null) {
        return;
      }

      List<ExecuteResult> executeResults = resultPair.getSecond();

      isLastScan = resultPair.getFirst();

      int effectNums = 0;

      for (ExecuteResult executeResult : executeResults) {
        isQuery = executeResult.isQuery();
        // Query
        if (executeResult.isQuery()) {
          Map<String, Pair<DataType, byte[]>> ret = executeResult.getMap();

          List<Value> values = New.arrayList();

          int i = 0;
          for (Map.Entry<String, Pair<DataType, byte[]>> stringPairEntry : ret
              .entrySet()) {
            String columnLabel = stringPairEntry.getKey();
            if (columnLabel.equalsIgnoreCase("rowkey")) {
              continue;
            }
            if (lableAliasInited == false) {
              mapColumn(aliasLabelMap, columnLabel, i++);
            }
            Pair<DataType, byte[]> typeAndValue = ret.get(columnLabel);
            Value v = Value.toValue(typeAndValue.getSecond(),
                typeAndValue.getFirst());
            values.add(v);
          }
          result.add(values.toArray(new Value[values.size()]));
          lableAliasInited = true;
        } else {
          OperationStatus operationStatus = executeResult.getStatus();

          // write
          if ((FConstants.OperationStatusCode.SUCCESS.name())
              .equals(operationStatus.getOperationStatusCode().name())) {
            effectNums++;
          } else if (((FConstants.OperationStatusCode.FAILURE.name())
              .equals(operationStatus.getOperationStatusCode().name()))) {
            String exceptionClassName = operationStatus.getExceptionClassname();
            String exceptionMsg = operationStatus.getExceptionMsg();

            if (StringUtils.isNullOrEmpty(exceptionClassName)) {
              continue;
            }

            try {
              Class exceptionClazz = Class.forName(exceptionClassName);
              Constructor constructor = exceptionClazz
                  .getConstructor(String.class);
              Object exceptionObject = constructor.newInstance(exceptionMsg);
              if (exceptionObject instanceof ClientConcernedException) {
                ClientConcernedException exception = (ClientConcernedException) exceptionObject;
                throw new SQLException(JdbcException.get(
                    exception.getErrorCode(), exceptionMsg));
              }
            } catch (ClassNotFoundException e) {
              log.error("ClassNotFoundException with Exception class name "
                  + exceptionClassName, e);
              throw new RuntimeException(e);
View Full Code Here

TOP

Related Classes of com.alibaba.wasp.ClientConcernedException

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.