@Override protected final List<HostUpdateResult<?>> receiveResponse(final InputStream input) throws IOException { final Unmarshaller unmarshaller = getUnmarshaller(); unmarshaller.start(createByteInput(input)); expectHeader(unmarshaller, DomainClientProtocol.RETURN_APPLY_UPDATES_RESULT_COUNT); final int updateCount = unmarshaller.readInt(); final List<HostUpdateResult<?>> results = new ArrayList<HostUpdateResult<?>>(updateCount); for (int i = 0; i < updateCount; i++) { expectHeader(unmarshaller, DomainClientProtocol.RETURN_APPLY_HOST_UPDATE); HostUpdateResult<?> updateResult = unmarshal(unmarshaller, HostUpdateResult.class); results.add(updateResult); } unmarshaller.finish(); return results; } }
private static Marshaller getMarshaller() throws IOException { return ProtocolUtils.getMarshaller(CONFIG); }
private static Unmarshaller getUnmarshaller() throws IOException { return ProtocolUtils.getUnmarshaller(CONFIG); }
private ServerIdentity readServerIdentity() throws IOException { expectHeader(DomainClientProtocol.RETURN_HOST_NAME); // Note: all StreamedResponse object values are marshalled as object, not UTF String hostName = unmarshal(unmarshaller, String.class); expectHeader(DomainClientProtocol.RETURN_SERVER_GROUP_NAME); String groupName = unmarshal(unmarshaller, String.class); expectHeader(DomainClientProtocol.RETURN_SERVER_NAME); String serverName = unmarshal(unmarshaller, String.class); return new ServerIdentity(hostName, groupName, serverName); }
@Override protected final List<String> receiveResponse(final InputStream input) throws IOException { final Unmarshaller unmarshaller = getUnmarshaller(); unmarshaller.start(createByteInput(input)); expectHeader(unmarshaller, DomainClientProtocol.RETURN_SERVER_MANAGER_COUNT); final int count = unmarshaller.readInt(); final List<String> results = new ArrayList<String>(count); for (int i = 0; i < count; i++) { expectHeader(unmarshaller, DomainClientProtocol.RETURN_HOST_NAME); results.add(unmarshaller.readUTF()); } unmarshaller.finish(); return results; } }
private byte readDeploymentSetRollback(Map<UUID, DeploymentSetPlanResult> setResults) throws IOException { UUID setId = unmarshal(unmarshaller, UUID.class); DeploymentSetPlanResult setResult = setResults.get(setId); if (setResult == null) { throw new IOException("Unknown deployment set plan " + setId); } // A valid deployment set plan will have at least one action byte nextHeader = unmarshaller.readByte(); expectHeader(nextHeader, DomainClientProtocol.RETURN_DEPLOYMENT_ACTION_ID); do { nextHeader = readDeploymentActionRollback(setResult); } while (nextHeader != DomainClientProtocol.RETURN_DEPLOYMENT_ACTION_ID); // If the set plan generated server updates, those will come next if (nextHeader == DomainClientProtocol.RETURN_SERVER_DEPLOYMENT_ROLLBACK) { do { nextHeader = readServerDeploymentRollback(setResult); } while(nextHeader == DomainClientProtocol.RETURN_SERVER_DEPLOYMENT_ROLLBACK); } return nextHeader; }
@Override protected final byte[] receiveResponse(final InputStream inputStream) throws IOException { ByteDataInput input = null; try { input = new SimpleByteDataInput(inputStream); expectHeader(input, DomainClientProtocol.RETURN_DEPLOYMENT_HASH_LENGTH); int length = input.readInt(); byte[] hash = new byte[length]; expectHeader(input, DomainClientProtocol.RETURN_DEPLOYMENT_HASH); input.readFully(hash); return hash; } finally { safeClose(input); } } }
@Override protected final DomainUpdateApplierResponse receiveResponse(final InputStream input) throws IOException { final Unmarshaller unmarshaller = getUnmarshaller(); unmarshaller.start(createByteInput(input)); expectHeader(unmarshaller, DomainClientProtocol.RETURN_APPLY_UPDATE); DomainUpdateApplierResponse rsp = unmarshal(unmarshaller, DomainUpdateApplierResponse.class); unmarshaller.finish(); return rsp; } }
private byte readDeploymentSetResult(final Map<UUID, DeploymentSetPlanResult>setResults) throws IOException { UUID setId = unmarshal(unmarshaller, UUID.class); DeploymentSetPlan setPlan = findDeploymentSet(setId); // will throw ISE if not found // A valid deployment set plan will have at least one action byte nextHeader = unmarshaller.readByte(); expectHeader(nextHeader, DomainClientProtocol.RETURN_DEPLOYMENT_ACTION_ID); // Next the server will send all the results of applying set plan updates to DC and SM domain model Map<UUID, DeploymentActionResult> actionResults = new HashMap<UUID, DeploymentActionResult>(); do { nextHeader = readDeploymentActionResult(setPlan, actionResults); } while (nextHeader == DomainClientProtocol.RETURN_DEPLOYMENT_ACTION_ID); // If the set plan generated server updates, those will come next if (nextHeader == DomainClientProtocol.RETURN_SERVER_DEPLOYMENT) { do { nextHeader = readServerDeploymentResult(actionResults); } while (nextHeader == DomainClientProtocol.RETURN_SERVER_DEPLOYMENT); } DeploymentSetPlanResult setResult = new DeploymentSetPlanResultImpl(setPlan, actionResults); setResults.put(setId, setResult); return nextHeader; }
/** {@inheritDoc} */ @Override protected final byte[] receiveResponse(final InputStream inputStream) throws IOException { ByteDataInput input = null; try { input = new SimpleByteDataInput(inputStream); expectHeader(input, StandaloneClientProtocol.PARAM_DEPLOYMENT_HASH_LENGTH); int length = input.readInt(); byte[] hash = new byte[length]; expectHeader(input, StandaloneClientProtocol.PARAM_DEPLOYMENT_HASH); input.readFully(hash); return hash; } finally { safeClose(input); } } }
private static Marshaller getMarshaller() throws IOException { return ProtocolUtils.getMarshaller(CONFIG); }
private static Unmarshaller getUnmarshaller() throws IOException { return ProtocolUtils.getUnmarshaller(CONFIG); }
@Override protected final DomainModel receiveResponse(final InputStream input) throws IOException { final Unmarshaller unmarshaller = getUnmarshaller(); unmarshaller.start(createByteInput(input)); expectHeader(unmarshaller, DomainClientProtocol.RETURN_DOMAIN_MODEL); final DomainModel domainModel = unmarshal(unmarshaller, DomainModel.class); unmarshaller.finish(); return domainModel; } }
public DeploymentPlanResult readResult() throws IOException { UUID planId = unmarshal(unmarshaller, UUID.class); if (!deploymentPlan.getId().equals(planId)) throw new IllegalStateException("Incorrect id " + planId + " for result; expected " + deploymentPlan.getId()); byte header = unmarshaller.readByte(); if (header == DomainClientProtocol.RETURN_DEPLOYMENT_PLAN_INVALID) { InvalidDeploymentPlanException e = unmarshal(unmarshaller, InvalidDeploymentPlanException.class); return new DeploymentPlanResultImpl(deploymentPlan, e);
@Override protected final Boolean receiveResponse(final InputStream inputStream) throws IOException { ByteDataInput input = null; try { input = new SimpleByteDataInput(inputStream); expectHeader(input, DomainClientProtocol.PARAM_DEPLOYMENT_NAME_UNIQUE); return input.readBoolean(); } finally { safeClose(input); } } }
@Override protected final ServerModel receiveResponse(final InputStream input) throws IOException { final Unmarshaller unmarshaller = getUnmarshaller(); unmarshaller.start(createByteInput(input)); expectHeader(unmarshaller, DomainClientProtocol.RETURN_SERVER_MODEL); final ServerModel serverModel = unmarshal(unmarshaller, ServerModel.class); unmarshaller.finish(); return serverModel; } }
private byte readDeploymentActionResult(final DeploymentSetPlan setPlan, final Map<UUID, DeploymentActionResult> actionResults) throws IOException { UUID actionId = unmarshal(unmarshaller, UUID.class); DeploymentActionImpl action = findDeploymentAction(actionId, setPlan); Set<DomainUpdateListener<?>> listeners = action.getListeners(); expectHeader(DomainClientProtocol.RETURN_DEPLOYMENT_ACTION_MODEL_RESULT); DomainUpdateApplierResponse duar = unmarshal(unmarshaller, DomainUpdateApplierResponse.class); DeploymentActionResultImpl actionResult = new DeploymentActionResultImpl(action, duar); actionResults.put(actionId, actionResult); // Notify any listeners for (DomainUpdateListener<?> listener : listeners) { if (duar.isCancelled()) { listener.handleCancelledByDomain(); } else if (duar.isRolledBack()) { listener.handleDomainRollback(); } else if (duar.getDomainFailure() != null) { listener.handleDomainFailed(duar.getDomainFailure()); } else if (duar.getHostFailures().size() > 0) { listener.handleHostFailed(duar.getHostFailures()); } else { listener.handleServersIdentified(duar.getServers()); } } return unmarshaller.readByte(); }
/** {@inheritDoc} */ @Override protected final Boolean receiveResponse(final InputStream inputStream) throws IOException { ByteDataInput input = null; try { input = new SimpleByteDataInput(inputStream); expectHeader(input, StandaloneClientProtocol.PARAM_DEPLOYMENT_NAME_UNIQUE); return input.readBoolean(); } finally { safeClose(input); } } }
/** {@inheritDoc} */ @Override protected ServerModel receiveResponse(InputStream input) throws IOException { final Unmarshaller unmarshaller = getUnmarshaller(); unmarshaller.start(createByteInput(input)); expectHeader(unmarshaller, StandaloneClientProtocol.PARAM_SERVER_MODEL); final ServerModel serverModel = unmarshal(unmarshaller, ServerModel.class); unmarshaller.finish(); return serverModel; } }
private byte readServerDeploymentRollback(DeploymentSetPlanResult setResult) throws IOException { UUID actionId = unmarshal(unmarshaller, UUID.class); DeploymentActionResultImpl actionResult = (DeploymentActionResultImpl) setResult.getDeploymentActionResults().get(actionId); ServerIdentity serverId = readServerIdentity(); expectHeader(DomainClientProtocol.RETURN_SERVER_DEPLOYMENT_RESULT); @SuppressWarnings("unchecked") UpdateResultHandlerResponse<Void> urhr = unmarshal(unmarshaller, UpdateResultHandlerResponse.class);