Package com.streamreduce.core.model

Examples of com.streamreduce.core.model.SystemInfo


        bootstrapUsersAndAccounts();
    }

    private void bootstrapSystemInfo() {
        ResourceBundle resourceBundle = ResourceBundle.getBundle("application");
        SystemInfo systemStatus = systemStatusDAO.getLatest();
        if (systemStatus == null) {
            systemStatus = new SystemInfo();
        }
        systemStatus.setAppVersion(resourceBundle.getString("nodeable.version"));
        systemStatus.setBuildNumber(resourceBundle.getString("nodeable.build"));
        systemStatusDAO.save(systemStatus);
    }
View Full Code Here


        systemStatusDAO.save(systemStatus);
    }


    private void doPatch() {
        SystemInfo systemInfo = systemStatusDAO.getLatest();

        // the current patch version application is running
        Integer currentPatchLevel = systemInfo.getPatchLevel();

        // if it's not set in the db... should only ever happen once (unless you dropped your db)
        if (currentPatchLevel == null) {
            currentPatchLevel = 0;
        }

        // from the properties, this is what we should apply
        Integer latestPatchAvailable = new Integer(latestPatch);
        logger.info("[BOOTSTRAP] db is at patch level " + currentPatchLevel);
        logger.info("[BOOTSTRAP] available patch number is " + latestPatchAvailable);

        // See if there is anything to do
        if (!isPatchRequired()) {
            logger.info("[BOOTSTRAP] nothing to do, exiting doPatch()");
            return;
        }

        // check to see if this host is the PatchMaster, all others are blocked until completion
        try {
            String hostname = java.net.InetAddress.getLocalHost().getHostName();
            if (!hostname.equals(patchMaster)) {

                // sleep, waking periodically to see if the patch is done.
                while (isPatchRequired()) {
                    logger.info("[BOOTSTRAP]" + hostname + " sleeping while db is locked and patches are applied.");
                    Thread.sleep(3000); // 3 second nap
                }
                logger.info("[BOOTSTRAP]" + hostname + " waking from sleep and booting, patch master is done.");
                // done, continue the boot process
                return;
            }

        } catch (Exception e) {
            logger.error("[BOOTSTRAP] patch failure: " + e.getMessage());
            throw new RuntimeException("[BOOTSTRAP] patch failure, terminating." + e.getMessage());
        }

        // apply patches if you are the patch master
        while (currentPatchLevel < latestPatchAvailable) {
            try {
                currentPatchLevel = currentPatchLevel + 1;

                Patch patch = (Patch) applicationContext.getBean("patch" + currentPatchLevel);
                if (patch == null) {
                    logger.info("[BOOTSTRAP] class not found for patch" + currentPatchLevel);
                    logger.info("[BOOTSTRAP] patch " + currentPatchLevel + " not applied, exiting patch process");
                    break;
                }

                patch.applyPatch(applicationManager, applicationContext);

                // if it fails do no set this.. there is no "continue" here.
                systemInfo.setPatchLevel(currentPatchLevel);
                systemStatusDAO.save(systemInfo);

            } catch (PatchException e) {
                logger.info("[BOOTSTRAP] " + e.getMessage() + " patch " + currentPatchLevel + " not applied, exiting patch process");
                break;
View Full Code Here

            logger.info("[BOOTSTRAP] patch " + currentPatchLevel + " successfully applied");
        }
    }

    private boolean isPatchRequired() {
        SystemInfo systemInfo = systemStatusDAO.getLatest();
        Integer currentPatchLevel = systemInfo.getPatchLevel();
        return currentPatchLevel == null || currentPatchLevel < new Integer(latestPatch);
    }
View Full Code Here

TOP

Related Classes of com.streamreduce.core.model.SystemInfo

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.