コード例 #1
0
ファイル: SfcProviderRpc.java プロジェクト: 8Uchi29/sfc
  /**
   * This method gets all necessary information for a system to construct a NSH header and
   * associated overlay packet to target the first service hop of a Rendered Service Path
   *
   * <p>
   *
   * @param input RPC input including a Rendered Service Path name
   * @return RPC output including a renderedServicePathFirstHop.
   */
  @Override
  public Future<RpcResult<ReadRenderedServicePathFirstHopOutput>> readRenderedServicePathFirstHop(
      ReadRenderedServicePathFirstHopInput input) {

    RenderedServicePathFirstHop renderedServicePathFirstHop = null;
    RpcResultBuilder<ReadRenderedServicePathFirstHopOutput> rpcResultBuilder;

    renderedServicePathFirstHop =
        SfcProviderRenderedPathAPI.readRenderedServicePathFirstHop(input.getName());

    ReadRenderedServicePathFirstHopOutput renderedServicePathFirstHopOutput = null;
    if (renderedServicePathFirstHop != null) {
      ReadRenderedServicePathFirstHopOutputBuilder renderedServicePathFirstHopOutputBuilder =
          new ReadRenderedServicePathFirstHopOutputBuilder();
      renderedServicePathFirstHopOutputBuilder.setRenderedServicePathFirstHop(
          renderedServicePathFirstHop);
      renderedServicePathFirstHopOutput = renderedServicePathFirstHopOutputBuilder.build();

      rpcResultBuilder = RpcResultBuilder.success(renderedServicePathFirstHopOutput);
    } else {
      String message = "Error Reading RSP First Hop from DataStore: " + input.getName();
      rpcResultBuilder =
          RpcResultBuilder.<ReadRenderedServicePathFirstHopOutput>failed()
              .withError(ErrorType.APPLICATION, message);
    }

    return Futures.immediateFuture(rpcResultBuilder.build());
  }
コード例 #2
0
ファイル: SfcProviderRpc.java プロジェクト: 8Uchi29/sfc
  @Override
  public Future<RpcResult<DeleteRenderedPathOutput>> deleteRenderedPath(
      DeleteRenderedPathInput input) {

    boolean ret;
    RpcResultBuilder<DeleteRenderedPathOutput> rpcResultBuilder;
    // If a RSP is deleted we delete both SF and SFF operational states.
    SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderStateExecutor(input.getName());
    SfcProviderServiceFunctionAPI.deleteServicePathFromServiceFunctionStateExecutor(
        input.getName());

    ret = SfcProviderRenderedPathAPI.deleteRenderedServicePathExecutor(input.getName());
    DeleteRenderedPathOutputBuilder deleteRenderedPathOutputBuilder =
        new DeleteRenderedPathOutputBuilder();
    deleteRenderedPathOutputBuilder.setResult(ret);
    if (ret) {
      rpcResultBuilder = RpcResultBuilder.success(deleteRenderedPathOutputBuilder.build());
    } else {
      String message = "Error Deleting Rendered Service Path: " + input.getName();
      rpcResultBuilder =
          RpcResultBuilder.<DeleteRenderedPathOutput>failed()
              .withError(ErrorType.APPLICATION, message);
    }

    return Futures.immediateFuture(rpcResultBuilder.build());
  }
コード例 #3
0
 @Override
 public RpcResult<TransactionStatus> apply(final DOMRpcResult input) {
   if (isSuccess(input)) {
     return RpcResultBuilder.success(TransactionStatus.COMMITED).build();
   } else {
     final RpcResultBuilder<TransactionStatus> failed = RpcResultBuilder.failed();
     for (final RpcError rpcError : input.getErrors()) {
       failed.withError(
           rpcError.getErrorType(),
           rpcError.getTag(),
           rpcError.getMessage(),
           rpcError.getApplicationTag(),
           rpcError.getInfo(),
           rpcError.getCause());
     }
     return failed.build();
   }
 }
コード例 #4
0
ファイル: SfcProviderRpc.java プロジェクト: 8Uchi29/sfc
  /**
   * This method reads all the necessary information for the first hop of a Rendered Service Path by
   * ServiceFunctionTypeIdentity list.
   *
   * <p>
   *
   * @param input RPC input including a ServiceFunctionTypeIdentity list
   * @return RPC output including a renderedServicePathFirstHop.
   */
  @Override
  public Future<RpcResult<ReadRspFirstHopBySftListOutput>> readRspFirstHopBySftList(
      ReadRspFirstHopBySftListInput input) {
    RenderedServicePathFirstHop renderedServicePathFirstHop = null;
    renderedServicePathFirstHop =
        SfcProviderRenderedPathAPI.readRspFirstHopBySftList(input.getSfst(), input.getSftList());
    ReadRspFirstHopBySftListOutput readRspFirstHopBySftListOutput = null;
    if (renderedServicePathFirstHop != null) {
      ReadRspFirstHopBySftListOutputBuilder readRspFirstHopBySftListOutputBuilder =
          new ReadRspFirstHopBySftListOutputBuilder();
      readRspFirstHopBySftListOutputBuilder.setRenderedServicePathFirstHop(
          renderedServicePathFirstHop);
      readRspFirstHopBySftListOutput = readRspFirstHopBySftListOutputBuilder.build();
    }

    RpcResultBuilder<ReadRspFirstHopBySftListOutput> rpcResultBuilder =
        RpcResultBuilder.success(readRspFirstHopBySftListOutput);
    return Futures.immediateFuture(rpcResultBuilder.build());
  }