Examples of MHost


Examples of com.webobjects.monitor._private.MHost

        return HostsPage.create(context());
    }

    public WOComponent removeHostClicked() {

        final MHost host = currentHost;

        return ConfirmationPage.create(context(), new ConfirmationPage.Delegate() {

            public WOComponent cancel() {
                return HostsPage.create(context());
            }

            public WOComponent confirm() {
                handler().startWriting();
                try {
                    siteConfig().removeHost_M(host);
                    NSMutableArray tempHostArray = new NSMutableArray(siteConfig().hostArray());
                    tempHostArray.addObject(host);

                    handler().sendRemoveHostToWotaskds(host, tempHostArray);
                } finally {
                    handler().endWriting();
                }
                return HostsPage.create(context());
            }

            public String explaination() {
                return "Selecting 'Yes' will shutdown any running instances of this host, and remove those instance configurations.";
            }

            public int pageType() {
                return HOST_PAGE;
            }

            public String question() {
                return "Are you sure you want to delete the host <I>" + host.name() + "</I>?";
            }

        });
    }
View Full Code Here

Examples of com.webobjects.monitor._private.MHost

        NSMutableArray<MInstance> runningInstances = new NSMutableArray<MInstance>();
        NSMutableSet<MHost> activeHosts = new NSMutableSet<MHost>();
        NSMutableDictionary<MHost, NSMutableArray<MInstance>> inactiveInstancesByHost = new NSMutableDictionary<MHost, NSMutableArray<MInstance>>();
        NSMutableDictionary<MHost, NSMutableArray<MInstance>> activeInstancesByHost = new NSMutableDictionary<MHost, NSMutableArray<MInstance>>();
        for (MInstance instance : instances) {
            MHost host = instance.host();
            if (instance.isRunning_M()) {
                runningInstances.addObject(instance);
                activeHosts.addObject(host);
                NSMutableArray<MInstance> currentInstances = activeInstancesByHost.objectForKey(host);
                if (currentInstances == null) {
                    currentInstances = new NSMutableArray<MInstance>();
                    activeInstancesByHost.setObjectForKey(currentInstances, host);
                }
                currentInstances.addObject(instance);
            } else {
                NSMutableArray<MInstance> currentInstances = inactiveInstancesByHost.objectForKey(host);
                if (currentInstances == null) {
                    currentInstances = new NSMutableArray<MInstance>();
                    inactiveInstancesByHost.setObjectForKey(currentInstances, host);
                }
                currentInstances.addObject(instance);
            }
        }
       
        if (inactiveInstancesByHost.isEmpty()) {
          addObjectsFromArrayIfAbsentToErrorMessageArray(
              new NSArray<String>("You must have at least one inactive instance to perform a graceful bounce."));
          return;
        }
       
        int numToStartPerHost = 1;
        if (activeHosts.count() > 0) {
            numToStartPerHost = (int) (runningInstances.count() / activeHosts.count() * .1);
        }
        if (numToStartPerHost < 1) {
            numToStartPerHost = 1;
        }
        boolean useScheduling = true;

        for (MInstance instance : runningInstances) {
            useScheduling &= instance.schedulingEnabled() != null && instance.schedulingEnabled().booleanValue();
        }

        NSMutableArray<MInstance> startingInstances = new NSMutableArray<MInstance>();
        for (int i = 0; i < numToStartPerHost; i++) {
            for (MHost host : activeHosts) {
                NSArray<MInstance> inactiveInstances = inactiveInstancesByHost.objectForKey(host);
                if (inactiveInstances != null && inactiveInstances.count() >= i) {
                    MInstance instance = inactiveInstances.objectAtIndex(i);
                    log("Starting inactive instance " + instance.displayName() + " on host " + host.addressAsString());
                    startingInstances.addObject(instance);
                } else {
                    log("Not enough inactive instances on host: " + host.addressAsString());
                }
            }
        }
        for (MInstance instance : startingInstances) {
            if (useScheduling) {
View Full Code Here

Examples of com.webobjects.monitor._private.MHost

        NSArray<MInstance> instances = application().instanceArray().immutableClone();
        NSMutableArray<MInstance> runningInstances = new NSMutableArray<MInstance>();
        NSMutableSet<MHost> activeHosts = new NSMutableSet<MHost>();
        for (MInstance instance : instances) {
            MHost host = instance.host();
            if (instance.isRunning_M()) {
                runningInstances.addObject(instance);
                activeHosts.addObject(host);
            }
        }
View Full Code Here

Examples of com.webobjects.monitor._private.MHost

    }

    public WOComponent saveMoving() {
        handler().startReading();
        try {
            MHost mhost;
            NSArray hosts = siteConfig().hostArray();
            for (Enumeration enumeration = hosts.objectEnumerator(); enumeration.hasMoreElements(); ) {
                mhost = (MHost) enumeration.nextElement();
                handler().sendOverwriteToWotaskd(mhost);
            }
View Full Code Here

Examples of com.webobjects.monitor._private.MHost

  }

  public WOComponent configureHostClicked() {
    handler().startWriting();
    try {
      MHost host = myHost();

      if ((_hostTypeSelection != null) && (!(_hostTypeSelection.toUpperCase().equals(host.osType())))) {
        host.setOsType(_hostTypeSelection.toUpperCase());
        handler().sendUpdateHostToWotaskds(host, siteConfig().hostArray());
      }
    } finally {
      handler().endWriting();
    }
View Full Code Here

Examples of com.webobjects.monitor._private.MHost

    }

    public String outputDiff() {
        MInstance myInstance = myInstance();
        MApplication myApplication = myInstance.application();
        MHost myHost = myInstance.host();
        String appOutputPath = null;

        if (myHost.osType().equals("UNIX")) {
            appOutputPath = myInstance.generateOutputPath(myApplication.unixOutputPath());
        } else if (myHost.osType().equals("WINDOWS")) {
            appOutputPath = myInstance.generateOutputPath(myApplication.winOutputPath());
        } else if (myHost.osType().equals("MACOSX")) {
            appOutputPath = myInstance.generateOutputPath(myApplication.macOutputPath());
        }

        if (!safeEquals(myInstance.outputPath(), appOutputPath)) {
            return _diffString;
View Full Code Here

Examples of com.webobjects.monitor._private.MHost

    return HostConfigurePage.create(context(), myHost());
  }

  public WOComponent syncHostClicked() {
    MHost host = myHost();
    siteConfig().hostErrorArray.addObjectIfAbsent(host);
    handler().sendUpdateHostToWotaskds(host, new NSArray(host));

    return HostConfigurePage.create(context(), myHost());
  }
View Full Code Here

Examples of com.webobjects.monitor._private.MHost

                            // update-remove - for each host listed - hostWithName + (stopAllInstances/new siteConfig) | removeHost_W
                            for (Enumeration e = hostArray.objectEnumerator(); e.hasMoreElements(); ) {
                                NSDictionary aHost = (NSDictionary) e.nextElement();
                                String name = (String) aHost.valueForKey("name");
                                MHost anMHost = aConfig.hostWithName(name);
                                if (anMHost == null) {
                                    element = new NSDictionary(new Object[]{Boolean.FALSE, _hostName + ": Host " +name+ " not found; REMOVE failed"}, errorKeys);
                                    hostArrayResponse.addObject(element);
                                } else {
                                    if ( anMHost == aConfig.localHost()) {
                                        stopAllInstances();
                                        ( (Application) WOApplication.application()).setSiteConfig(new MSiteConfig(null));
                                    } else {
                                        aConfig.removeHost_W(anMHost);
                                    }
                                    hostArrayResponse.addObject(successElement);
                                }
                            }
                            removeResponse.takeValueForKey(hostArrayResponse, "hostArray");
                        }
                        if (applicationArray != null) {
                            NSMutableArray applicationArrayResponse = new NSMutableArray(applicationArray.count());

                            // update-remove - for each application listed - applicationWithName + removeApplication_W
                            for (Enumeration e = applicationArray.objectEnumerator(); e.hasMoreElements(); ) {
                                NSDictionary anApp = (NSDictionary) e.nextElement();
                                String name = (String) anApp.valueForKey("name");
                                MApplication anMApplication = aConfig.applicationWithName(name);
                                if (anMApplication == null) {
                                    element = new NSDictionary(new Object[]{Boolean.FALSE, _hostName + ": Application " +name+ " not found; REMOVE failed"}, errorKeys);
                                    applicationArrayResponse.addObject(element);
                                } else {
                                    aConfig.removeApplication_W(aConfig.applicationWithName(name));
                                    applicationArrayResponse.addObject(successElement);
                                }
                            }
                            removeResponse.takeValueForKey(applicationArrayResponse, "applicationArray");
                        }
                        if (instanceArray != null) {
                            NSMutableArray instanceArrayResponse = new NSMutableArray(instanceArray.count());

                            // update-remove - for each instance listed - instanceWithHostnameAndPort + removeInstance_W
                            for (Enumeration e = instanceArray.objectEnumerator(); e.hasMoreElements(); ) {
                                NSDictionary anInst = (NSDictionary) e.nextElement();
                                String hostName = (String) anInst.valueForKey("hostName");
                                Integer port = (Integer) anInst.valueForKey("port");
                                MInstance anMInstance = aConfig.instanceWithHostnameAndPort(hostName, port);
                                if (anMInstance == null) {
                                    element = new NSDictionary(new Object[]{Boolean.FALSE, _hostName + ": Instance " +hostName+"-"+port+ " not found; REMOVE failed"}, errorKeys);
                                    instanceArrayResponse.addObject(element);
                                } else {
                                    aConfig.removeInstance_W(anMInstance);
                                    instanceArrayResponse.addObject(successElement);
                                }
                            }
                            removeResponse.takeValueForKey(instanceArrayResponse, "instanceArray");
                        }
                        updateWotaskdResponse.takeValueForKey(removeResponse, "remove");
                    }

                    if (addDict != null) {
                        NSMutableDictionary addResponse = new NSMutableDictionary(1);

                        NSArray hostArray = (NSArray) addDict.valueForKey("hostArray");
                        NSArray applicationArray = (NSArray) addDict.valueForKey("applicationArray");
                        NSArray instanceArray = (NSArray) addDict.valueForKey("instanceArray");

                        if (hostArray != null) {
                            NSMutableArray hostArrayResponse = new NSMutableArray(hostArray.count());

                            // update-add - for each host listed - addHost_W
                            for (Enumeration e = hostArray.objectEnumerator(); e.hasMoreElements(); ) {
                                NSDictionary aHost = (NSDictionary) e.nextElement();
                                aConfig.addHost_W(new MHost(aHost, aConfig));
                                hostArrayResponse.addObject(successElement);
                            }
                            addResponse.takeValueForKey(hostArrayResponse, "hostArray");
                        }
                        if (applicationArray != null) {
                            NSMutableArray applicationArrayResponse = new NSMutableArray(applicationArray.count());

                            // update-add - for each application listed - addApplication_W
                            for (Enumeration e = applicationArray.objectEnumerator(); e.hasMoreElements(); ) {
                                NSDictionary anApp = (NSDictionary) e.nextElement();
                                aConfig.addApplication_W(new MApplication(anApp, aConfig));
                                applicationArrayResponse.addObject(successElement);
                            }
                            addResponse.takeValueForKey(applicationArrayResponse, "applicationArray");
                        }
                        if (instanceArray != null) {
                            NSMutableArray instanceArrayResponse = new NSMutableArray(instanceArray.count());

                            //  update-add - for each instance listed - addInstance_W
                            for (Enumeration e = instanceArray.objectEnumerator(); e.hasMoreElements(); ) {
                                NSDictionary anInst = (NSDictionary) e.nextElement();
                                aConfig.addInstance_W(new MInstance(anInst, aConfig));
                                instanceArrayResponse.addObject(successElement);
                            }
                            addResponse.takeValueForKey(instanceArrayResponse, "instanceArray");
                        }
                        updateWotaskdResponse.takeValueForKey(addResponse, "add");
                    }

                    if (configureDict != null) {
                        NSMutableDictionary configureResponse = new NSMutableDictionary(2);

                        NSDictionary siteDict = (NSDictionary) configureDict.valueForKey("site");
                        NSArray hostArray = (NSArray) configureDict.valueForKey("hostArray");
                        NSArray applicationArray = (NSArray) configureDict.valueForKey("applicationArray");
                        NSArray instanceArray = (NSArray) configureDict.valueForKey("instanceArray");

                        if (siteDict != null) {
                            // update-configure - siteConfig.updateValues
                            aConfig.updateValues(siteDict);
                            configureResponse.takeValueForKey(successElement, "site");
                        }
                        if (hostArray != null) {
                            NSMutableArray hostArrayResponse = new NSMutableArray(hostArray.count());

                            // update-configure - for each host listed - hostWithName + updateValues
                            for (Enumeration e = hostArray.objectEnumerator(); e.hasMoreElements(); ) {
                                NSDictionary aHost = (NSDictionary) e.nextElement();
                                String name = (String) aHost.valueForKey("name");
                                MHost anMHost = aConfig.hostWithName(name);
                                if (anMHost == null) {
                                    element = new NSDictionary(new Object[]{Boolean.FALSE, _hostName + ": Host " +name+ " not found; UPDATE failed"}, errorKeys);
                                    hostArrayResponse.addObject(element);
                                } else {
                                    anMHost.updateValues(aHost);
                                    hostArrayResponse.addObject(successElement);
                                }
                            }
                            configureResponse.takeValueForKey(hostArrayResponse, "hostArray");
                        }
View Full Code Here

Examples of com.webobjects.monitor._private.MHost

        NSMutableArray currentHosts = new NSMutableArray(aConfig.hostArray());
        if (hostArray != null) {
            for (Enumeration e = hostArray.objectEnumerator(); e.hasMoreElements(); ) {
                NSDictionary aHost = (NSDictionary) e.nextElement();
                String name = (String) aHost.valueForKey("name");
                MHost anMHost = aConfig.hostWithName(name);
                if (anMHost == null) {
                    // we have to add it
                    aConfig.addHost_W(new MHost(aHost, aConfig));
                } else {
                    // configure and remove from currentHosts
                    anMHost.updateValues(aHost);
                    currentHosts.removeObject(anMHost);
                }
            }
        }
        // remove all hosts remaining in currentHosts
        for (Enumeration e = currentHosts.objectEnumerator(); e.hasMoreElements(); ) {
            MHost anMHost = (MHost) e.nextElement();
            if ( anMHost == aConfig.localHost()) {
                stopAllInstances();
                ( (Application) WOApplication.application()).setSiteConfig(new MSiteConfig(null));
                break;
            }
View Full Code Here

Examples of com.webobjects.monitor._private.MHost

    }

    public String pathDiff() {
        MInstance myInstance = myInstance();
        MApplication myApplication = myInstance.application();
        MHost myHost = myInstance.host();
        String appPath = null;

        if (myHost.osType().equals("UNIX")) {
            appPath = myApplication.unixPath();
        } else if (myHost.osType().equals("WINDOWS")) {
            appPath = myApplication.winPath();
        } else if (myHost.osType().equals("MACOSX")) {
            appPath = myApplication.macPath();
        }

        if (!safeEquals(myInstance.path(), appPath)) {
            return _diffString;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.