public GreengrassCoreIPCClientV2 build()

in sdk/greengrass/greengrass-client/src/event-stream-rpc-java/client/software/amazon/awssdk/aws/greengrass/GreengrassCoreIPCClientV2.java [1428:1467]


    public GreengrassCoreIPCClientV2 build() throws IOException {
      if (client == null) {
        String ipcServerSocketPath = this.socketPath;
        String authToken = this.authToken;
        try (EventLoopGroup elGroup = new EventLoopGroup(1);
             ClientBootstrap clientBootstrap = new ClientBootstrap(elGroup, null);
             SocketOptions socketOptions = new SocketOptions()) {
          socketOptions.connectTimeoutMs = 3000;
          socketOptions.domain = this.socketDomain;
          socketOptions.type = SocketOptions.SocketType.STREAM;

          final EventStreamRPCConnectionConfig config = new EventStreamRPCConnectionConfig(clientBootstrap, elGroup, socketOptions, null, ipcServerSocketPath, this.port, GreengrassConnectMessageSupplier.connectMessageSupplier(authToken));
          connection = new EventStreamRPCConnection(config);
          CompletableFuture<Void> connected = new CompletableFuture<>();
          connection.connect(new EventStreamRPCConnection.LifecycleHandler() {
            @Override public void onConnect() {
              connected.complete(null);
            }
            @Override public void onDisconnect(int errorCode) {
            }
            @Override public boolean onError(Throwable t) {
              connected.completeExceptionally(t);
              return true;
            }
          } );
          try {
            connected.get();
          }
          catch (ExecutionException | InterruptedException e) {
            connection.close();
            throw new IOException(e);
          }
          this.client = new GreengrassCoreIPCClient(connection);
        }
      }
      if (this.useExecutor && this.executor == null) {
        this.executor = Executors.newCachedThreadPool();
      }
      return new GreengrassCoreIPCClientV2(this.client, this.connection, this.executor);
    }