@Override void handleRequest(String hostId, DataInput input, ManagementRequestContext<Void> context) throws IOException { final RootFileReader reader = new RootFileReader() { public File readRootFile(byte rootId, String filePath) throws RequestProcessingException { final HostFileRepository localFileRepository = domainController.getLocalFileRepository(); switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { return localFileRepository.getFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { return localFileRepository.getConfigurationFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); return localFileRepository.getDeploymentRoot(hash); } default: { throw MESSAGES.invalidRootId(rootId); } } } }; remoteSupport.handleRequest(input, reader, context); } }
@Override protected void sendRequest(ActiveOperation.ResultHandler<File> resultHandler, ManagementRequestContext<Void> context, FlushableDataOutput output) throws IOException { output.write(DomainControllerProtocol.PARAM_HOST_ID); output.writeUTF(localHostInfo.getLocalHostName()); DomainRemoteFileRequestAndHandler.INSTANCE.sendRequest(output, rootId, filePath); }
@Override public void handleRequest(DataInput input, ActiveOperation.ResultHandler<File> resultHandler, ManagementRequestContext<Void> context) throws IOException { final File localPath; switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { localPath = localFileRepository.getFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { localPath = localFileRepository.getConfigurationFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); localPath = localFileRepository.getDeploymentRoot(hash); break; } default: { localPath = null; } } try { DomainRemoteFileRequestAndHandler.INSTANCE.handleResponse(input, localPath, ROOT_LOGGER, resultHandler, context); } catch (CannotCreateLocalDirectoryException e) { throw MESSAGES.cannotCreateLocalDirectory(e.getDir()); } catch (DidNotReadEntireFileException e) { throw MESSAGES.didNotReadEntireFile(e.getMissing()); } } }
@Override public void handleRequest(DataInput input, ActiveOperation.ResultHandler<File> resultHandler, ManagementRequestContext<Void> context) throws IOException { final File localPath; switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { localPath = localFileRepository.getFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { localPath = localFileRepository.getConfigurationFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); localPath = localFileRepository.getDeploymentRoot(new ContentReference(filePath, hash)); break; } default: { localPath = null; } } try { DomainRemoteFileRequestAndHandler.INSTANCE.handleResponse(input, localPath, ROOT_LOGGER, resultHandler, context); } catch (CannotCreateLocalDirectoryException e) { throw HostControllerLogger.ROOT_LOGGER.cannotCreateLocalDirectory(e.getDir()); } catch (DidNotReadEntireFileException e) { throw HostControllerLogger.ROOT_LOGGER.didNotReadEntireFile(e.getMissing()); } } }
@Override protected void sendRequest(ActiveOperation.ResultHandler<File> resultHandler, ManagementRequestContext<Void> context, FlushableDataOutput output) throws IOException { output.write(DomainControllerProtocol.PARAM_HOST_ID); output.writeUTF(localHostInfo.getLocalHostName()); DomainRemoteFileRequestAndHandler.INSTANCE.sendRequest(output, rootId, filePath); }
@Override void handleRequest(String hostId, DataInput input, ActiveOperation.ResultHandler<Void> resultHandler, ManagementRequestContext<Void> context) throws IOException { DomainControllerLogger.ROOT_LOGGER.tracef("Handling GetFileOperation with id %d from %s", context.getOperationId(), hostId); final RootFileReader reader = new RootFileReader() { public File readRootFile(byte rootId, String filePath) throws RequestProcessingException { final HostFileRepository localFileRepository = domainController.getLocalFileRepository(); switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { return localFileRepository.getFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { return localFileRepository.getConfigurationFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); return localFileRepository.getDeploymentRoot(new ContentReference(filePath, hash)); } default: { throw HostControllerLogger.ROOT_LOGGER.invalidRootId(rootId); } } } }; remoteSupport.handleRequest(input, reader, resultHandler, context); } }
@Override public void handleRequest(DataInput input, ActiveOperation.ResultHandler<File> resultHandler, ManagementRequestContext<Void> context) throws IOException { final File localPath; switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { localPath = localFileRepository.getFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { localPath = localFileRepository.getConfigurationFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); localPath = localFileRepository.getDeploymentRoot(new ContentReference(filePath, hash)); break; } default: { localPath = null; } } try { DomainRemoteFileRequestAndHandler.INSTANCE.handleResponse(input, localPath, ROOT_LOGGER, resultHandler, context); } catch (CannotCreateLocalDirectoryException e) { throw HostControllerLogger.ROOT_LOGGER.cannotCreateLocalDirectory(e.getDir()); } catch (DidNotReadEntireFileException e) { throw HostControllerLogger.ROOT_LOGGER.didNotReadEntireFile(e.getMissing()); } } }
@Override protected void sendRequest(ActiveOperation.ResultHandler<File> resultHandler, ManagementRequestContext<Void> context, FlushableDataOutput output) throws IOException { output.write(DomainControllerProtocol.PARAM_HOST_ID); output.writeUTF(localHostInfo.getLocalHostName()); DomainRemoteFileRequestAndHandler.INSTANCE.sendRequest(output, rootId, filePath); }
@Override void handleRequest(String hostId, DataInput input, ActiveOperation.ResultHandler<Void> resultHandler, ManagementRequestContext<Void> context) throws IOException { DomainControllerLogger.ROOT_LOGGER.tracef("Handling GetFileOperation with id %d from %s", context.getOperationId(), hostId); final RootFileReader reader = new RootFileReader() { public File readRootFile(byte rootId, String filePath) throws RequestProcessingException { final HostFileRepository localFileRepository = domainController.getLocalFileRepository(); switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { return localFileRepository.getFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { return localFileRepository.getConfigurationFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); return localFileRepository.getDeploymentRoot(new ContentReference(filePath, hash)); } default: { throw HostControllerLogger.ROOT_LOGGER.invalidRootId(rootId); } } } }; remoteSupport.handleRequest(input, reader, resultHandler, context); } }