Package net.java.trueupdate.message

Examples of net.java.trueupdate.message.UpdateMessage


    @Override
    protected void onInstallationRequest(final UpdateMessage message)
    throws Exception {
        logReceived(message);
        subscribe(message);
        UpdateMessage response;
        try {
            install(message);
            response = installationSuccessResponse(message);
        } catch (Exception ex) {
            response = installationFailureResponse(message);
View Full Code Here


                sendRedeploymentRequest();
                final long stop = System.currentTimeMillis()
                        + HANDSHAKE_TIMEOUT_MILLIS;
                synchronized (sessionManager) {
                    while (true) {
                        final UpdateMessage um = sessionManager.get(request);
                        final Type type = um.type();
                        checkCancelled(type);
                        if (PROCEED_REDEPLOYMENT_RESPONSE.equals(type))
                            break;
                        final long remaining = stop - System.currentTimeMillis();
                        if (0 >= remaining)
                            throw new Exception(
                                    "Timeout while waiting for a redeployment response from the update agent.");
                        sessionManager.wait(remaining);
                    }
                }
            }

            void sendRedeploymentRequest() throws Exception {
                final UpdateMessage redeploymentRequest = responseFor(request)
                        .type(REDEPLOYMENT_REQUEST)
                        .artifactDescriptor(artifactDescriptor())
                        .build();
                sendAndLog(redeploymentRequest);
            }

            void checkCancelled(final Type type) throws Exception {
                if (CANCEL_REDEPLOYMENT_RESPONSE.equals(type))
                    throw new Exception(
                            "The update agent has cancelled the update installation.");
            }

            void onPerformUndeployment() {
                anticipatedDescriptor = request
                        .artifactDescriptor()
                        .update()
                        .version(request.updateVersion())
                        .build();
                anticipatedLocation = request.updateLocation();
            }

            void onRevertUndeployment() {
                anticipatedDescriptor = request.artifactDescriptor();
                anticipatedLocation = request.currentLocation();
            }

            Command checked(final Command cmd) {
                return new Command() {

                    @Override public void perform() throws Exception {
                        // Throw an InterruptedException if requested.
                        Thread.sleep(0);
                        // May be undeployed, so check for null.
                        final UpdateMessage um = sessionManager.get(request);
                        if (null != um) checkCancelled(um.type());
                        cmd.perform();
                    }

                    @Override public void revert() throws Exception {
                        cmd.revert();
                    }
                };
            }

            @Override
            public void transmit(final LogRecord record) throws Exception {
                final UpdateMessage um = responseFor(request)
                        .type(PROGRESS_NOTICE)
                        .artifactDescriptor(anticipatedDescriptor)
                        .currentLocation(anticipatedLocation)
                        .build();
                um.attachedLogs().add(record);
                send(um);
            }
        } // Install

        new Install().call();
View Full Code Here

                sendRedeploymentRequest();
                final long stop = System.currentTimeMillis()
                        + HANDSHAKE_TIMEOUT_MILLIS;
                synchronized (sessionManager) {
                    while (true) {
                        final UpdateMessage um = sessionManager.get(request);
                        final Type type = um.type();
                        checkCancelled(type);
                        if (PROCEED_REDEPLOYMENT_RESPONSE.equals(type))
                            break;
                        final long remaining = stop - System.currentTimeMillis();
                        if (0 >= remaining)
View Full Code Here

        if (null == dto) return null;
        final ArtifactDescriptor ad = new ArtifactDescriptorAdapter()
                .unmarshal(dto.artifactDescriptor);
        final List<LogRecord> lrs = new LogRecordsAdapter()
                .unmarshal(dto.logRecords);
        final UpdateMessage um = UpdateMessage
                .builder()
                .timestamp(dto.timestamp)
                .from(dto.from)
                .to(dto.to)
                .type(Type.values()[dto.type])
                .artifactDescriptor(ad)
                .updateVersion(dto.updateVersion)
                .currentLocation(dto.currentLocation)
                .updateLocation(dto.updateLocation)
                .build();
        um.attachedLogs().addAll(lrs);
        return um;
    }
View Full Code Here

                    }
                }
            }

            void sendRedeploymentRequest() throws Exception {
                final UpdateMessage redeploymentRequest = responseFor(request)
                        .type(REDEPLOYMENT_REQUEST)
                        .artifactDescriptor(artifactDescriptor())
                        .build();
                sendAndLog(redeploymentRequest);
            }
View Full Code Here

                    @Override public void perform() throws Exception {
                        // Throw an InterruptedException if requested.
                        Thread.sleep(0);
                        // May be undeployed, so check for null.
                        final UpdateMessage um = sessionManager.get(request);
                        if (null != um) checkCancelled(um.type());
                        cmd.perform();
                    }

                    @Override public void revert() throws Exception {
                        cmd.revert();
View Full Code Here

                };
            }

            @Override
            public void transmit(final LogRecord record) throws Exception {
                final UpdateMessage um = responseFor(request)
                        .type(PROGRESS_NOTICE)
                        .artifactDescriptor(anticipatedDescriptor)
                        .currentLocation(anticipatedLocation)
                        .build();
                um.attachedLogs().add(record);
                send(um);
            }
View Full Code Here

TOP

Related Classes of net.java.trueupdate.message.UpdateMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.