public File getFile(final String relativePath, final byte repoId, final File localDeploymentFolder) { try { return channelHandler.executeRequest(new GetFileRequest(relativePath, localDeploymentFolder), null).getResult().get(); } catch (Exception e) { throw ServerLogger.ROOT_LOGGER.failedToGetFileFromRemoteRepository(e); } } }
/** * Execute a request. * * @param request the request * @param channel the channel * @param support the request support * @return the future result */ protected <T, A> AsyncFuture<T> executeRequest(final ManagementRequest<T, A> request, final Channel channel, final ActiveOperation<T, A> support) { assert support != null; updateChannelRef(support, channel); final Integer requestId = this.requestID.incrementAndGet(); final ActiveRequest<T, A> ar = new ActiveRequest<T, A>(support, request); requests.put(requestId, ar); final ManagementRequestHeader header = new ManagementRequestHeader(ManagementProtocol.VERSION, requestId, support.getOperationId(), request.getOperationType()); final ActiveOperation.ResultHandler<T> resultHandler = support.getResultHandler(); try { request.sendRequest(resultHandler, new ManagementRequestContextImpl<T, A>(support, channel, header, getExecutor())); } catch (Exception e) { resultHandler.failed(e); requests.remove(requestId); } return support.getResult(); }
public File getFile(final String relativePath, final byte repoId, final File localDeploymentFolder) { try { return channelHandler.executeRequest(new GetFileRequest(relativePath, localDeploymentFolder), null).getResult().get(); } catch (Exception e) { throw ServerMessages.MESSAGES.failedToGetFileFromRemoteRepository(e); } } }
public File getFile(final String relativePath, final byte repoId, final File localDeploymentFolder) { try { return channelHandler.executeRequest(new GetFileRequest(relativePath, localDeploymentFolder), null).getResult().get(); } catch (Exception e) { throw ServerLogger.ROOT_LOGGER.failedToGetFileFromRemoteRepository(e); } } }
protected AsyncFuture<OperationResponse> executeRequest(final ManagementRequest<OperationResponse, OperationExecutionContext> request, final OperationExecutionContext attachment) throws IOException { final ActiveOperation<OperationResponse, OperationExecutionContext> support = getChannelAssociation().executeRequest(request, attachment, attachment); return new DelegatingCancellableAsyncFuture(support.getResult(), support.getOperationId()); }
public File getFile(final String relativePath, final byte repoId, final File localDeploymentFolder) { try { return channelHandler.executeRequest(new GetFileRequest(relativePath, localDeploymentFolder), null).getResult().get(); } catch (Exception e) { throw ServerMessages.MESSAGES.failedToGetFileFromRemoteRepository(e); } } }
protected AsyncFuture<ModelNode> executeRequest(final ManagementRequest<ModelNode, OperationExecutionContext> request, final OperationExecutionContext attachment) throws IOException { final ActiveOperation<ModelNode, OperationExecutionContext> support = getChannelAssociation().executeRequest(request, attachment, attachment); return new DelegatingCancellableAsyncFuture(support.getResult(), support.getOperationId()); }
@Override public void close() throws IOException { synchronized (this) { try { if(isConnected()) { try { channelHandler.executeRequest(new UnregisterModelControllerRequest(), null).getResult().await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } finally { try { connectionManager.shutdown(); } finally { super.close(); } } } }
/** * Send the started notification */ synchronized void started() { try { if(isConnected()) { channelHandler.executeRequest(new ServerStartedRequest(), null).getResult().await(); } } catch (Exception e) { ServerLogger.AS_ROOT_LOGGER.debugf(e, "failed to send started notification"); } }
/** * Send the started notification */ synchronized void started() { try { if(isConnected()) { channelHandler.executeRequest(new ServerStartedRequest(), null).getResult().await(); } } catch (Exception e) { ServerLogger.AS_ROOT_LOGGER.debugf(e, "failed to send started notification"); } }
@Override public void close() throws IOException { try { if(prepareClose() && isConnected()) { try { channelHandler.executeRequest(new UnregisterModelControllerRequest(), null).getResult().await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } finally { try { super.close(); } finally { connectionManager.shutdown(); } } }
/** * Send the started notification */ synchronized void started() { try { if(isConnected()) { channelHandler.executeRequest(new ServerStartedRequest(), null).getResult().await(); } } catch (Exception e) { ServerLogger.AS_ROOT_LOGGER.debugf(e, "failed to send started notification"); } }
/** * Send the started notification */ synchronized void started() { try { if(isConnected()) { channelHandler.executeRequest(new ServerStartedRequest(), null).getResult().await(); } } catch (Exception e) { ServerLogger.AS_ROOT_LOGGER.debugf(e, "failed to send started notification"); } }
@Override public void close() throws IOException { try { if(prepareClose() && isConnected()) { try { channelHandler.executeRequest(new UnregisterModelControllerRequest(), null).getResult().await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } finally { try { super.close(); } finally { connectionManager.shutdown(); } } }
public File getFile(final String relativePath, final byte repoId, HostFileRepository localFileRepository) { if(connection.isConnected()) { try { return handler.executeRequest(new GetFileRequest(repoId, relativePath, localFileRepository), null).getResult().get(); } catch (Exception e) { throw MESSAGES.failedToGetFileFromRemoteRepository(e); } } else { return localFileRepository.getFile(relativePath); } } };
public File getFile(final String relativePath, final byte repoId, HostFileRepository localFileRepository) { if(connection.isConnected()) { try { return handler.executeRequest(new GetFileRequest(repoId, relativePath, localFileRepository), null).getResult().get(); } catch (Exception e) { throw HostControllerLogger.ROOT_LOGGER.failedToGetFileFromRemoteRepository(e); } } else { final File file = localFileRepository.getFile(relativePath); // using --cached-dc and the DC is unavailable, make sure the content exists locally. if (localHostInfo.isUsingCachedDc()) { if (! file.exists()) { throw HostControllerLogger.ROOT_LOGGER.failedToGetFileFromRemoteRepository(new RuntimeException("Content hash " + relativePath + " not found.")); } } return file; } } };
public File getFile(final String relativePath, final byte repoId, HostFileRepository localFileRepository) { if(connection.isConnected()) { try { return handler.executeRequest(new GetFileRequest(repoId, relativePath, localFileRepository), null).getResult().get(); } catch (Exception e) { throw HostControllerLogger.ROOT_LOGGER.failedToGetFileFromRemoteRepository(e); } } else { final File file = localFileRepository.getFile(relativePath); // using --cached-dc and the DC is unavailable, make sure the content exists locally. if (localHostInfo.isUsingCachedDc()) { if (! file.exists()) { throw HostControllerLogger.ROOT_LOGGER.failedToGetFileFromRemoteRepository(new RuntimeException("Content hash " + relativePath + " not found.")); } } return file; } } };
@Override public void connectionOpened(final Connection connection) throws IOException { final Channel channel = openChannel(connection, CHANNEL_SERVICE_TYPE, configuration.getOptionMap()); if(setChannel(channel)) { channel.receiveMessage(channelHandler.getReceiver()); channel.addCloseHandler(channelHandler); try { // Start the registration process channelHandler.executeRequest(new RegisterHostControllerRequest(), null).getResult().get(); } catch (Exception e) { if(e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new IOException(e); } // Registered registered(); } else { channel.closeAsync(); } }
@Override public <T extends Operation> AsyncFuture<ModelNode> execute(TransactionalOperationListener<T> listener, T operation) throws IOException { final ExecuteRequestContext context = new ExecuteRequestContext(new OperationWrapper<T>(listener, operation)); final ActiveOperation<ModelNode, ExecuteRequestContext> op = channelAssociation.initializeOperation(context, context); final AsyncFuture<ModelNode> result = new AbstractDelegatingAsyncFuture<ModelNode>(op.getResult()) { @Override public void asyncCancel(boolean interruptionDesired) { try { // Execute channelAssociation.executeRequest(op, new CompleteTxRequest(ModelControllerProtocol.PARAM_ROLLBACK)); } catch (Exception e) { throw new RuntimeException(e); } } }; context.initialize(result); channelAssociation.executeRequest(op, new ExecuteRequest()); return result; }
@Override public <T extends Operation> AsyncFuture<ModelNode> execute(TransactionalOperationListener<T> listener, T operation) throws IOException { final Subject subject = SecurityActions.getSubject(); final ExecuteRequestContext context = new ExecuteRequestContext(new OperationWrapper<T>(listener, operation), subject); final ActiveOperation<ModelNode, ExecuteRequestContext> op = channelAssociation.initializeOperation(context, context); final AsyncFuture<ModelNode> result = new AbstractDelegatingAsyncFuture<ModelNode>(op.getResult()) { @Override public void asyncCancel(boolean interruptionDesired) { try { // Execute channelAssociation.executeRequest(op, new CompleteTxRequest(ModelControllerProtocol.PARAM_ROLLBACK)); } catch (Exception e) { throw new RuntimeException(e); } } }; context.initialize(result); channelAssociation.executeRequest(op, new ExecuteRequest()); return result; }