Package com.webobjects.monitor._private

Examples of com.webobjects.monitor._private.MInstance


    public WOComponent schedulingEnableAllClicked() {
        handler().startReading();
        try {
            NSArray instancesArray = selectedInstances();
            for (int i = 0; i < instancesArray.count(); i++) {
                MInstance anInst = (MInstance) instancesArray.objectAtIndex(i);
                anInst.setSchedulingEnabled(Boolean.TRUE);
            }
            if (allHosts().count() != 0) {
                handler().sendUpdateInstancesToWotaskds(instancesArray, allHosts());
            }
        } finally {
View Full Code Here


      handler().endWriting();
    }
  }

  private void deleteInstance(MApplication application, Integer instanceId) {
    final MInstance instance = application.instanceWithID(instanceId);
    handler().startWriting();
    try {
      siteConfig().removeInstance_M(instance);
      if (siteConfig().hostArray().count() != 0) {
        handler().sendRemoveInstancesToWotaskds(new NSArray(instance), siteConfig().hostArray());
View Full Code Here

        }
        if (_InstanceArray != null) {
            int instanceCount = _InstanceArray.count();
            NSMutableArray instanceArray = new NSMutableArray(instanceCount);
            for (int i = 0; i < instanceCount; i++) {
                MInstance anInst = (MInstance) _InstanceArray.objectAtIndex(i);
                instanceArray.addObject(anInst.values());
            }
            requestTypeDict.takeValueForKey(instanceArray, "instanceArray");
        }

        updateWotaskd.takeValueForKey(requestTypeDict, requestType);
View Full Code Here

            NSMutableArray commandWotaskd = new NSMutableArray(instanceArray.count() + 1);

            commandWotaskd.addObject(command);

            for (int i = 0; i < instanceCount; i++) {
                MInstance anInst = (MInstance) instanceArray.objectAtIndex(i);
                commandWotaskd.addObject(new NSDictionary(new Object[] { anInst.applicationName(), anInst.id(),
                        anInst.hostName(), anInst.port() }, commandInstanceKeys));
            }
            monitorRequest.takeValueForKey(commandWotaskd, "commandWotaskd");

            WOResponse[] responses = collector.sendRequest(monitorRequest, wotaskdArray, false);
            NSDictionary[] responseDicts = collector.generateResponseDictionaries(responses);
View Full Code Here

                                    .valueForKey("refusingNewSessions");
                            NSDictionary statistics = (NSDictionary) responseDictionary.valueForKey("statistics");
                            NSArray deaths = (NSArray) responseDictionary.valueForKey("deaths");
                            String nextShutdown = (String) responseDictionary.valueForKey("nextShutdown");

                            MInstance anInstance = siteConfig().instanceWithHostnameAndPort(host, port);
                            if (anInstance != null) {
                                for (int k = 0; k < MObject.stateArray.length; k++) {
                                    if (MObject.stateArray[k].equals(runningState)) {
                                        anInstance.state = k;
                                        break;
                                    }
                                }
                                anInstance.setRefusingNewSessions(String_Extensions.boolValue(refusingNewSessions));
                                anInstance.setStatistics(statistics);
                                anInstance.setDeaths(new NSMutableArray(deaths));
                                anInstance.setNextScheduledShutdownString_M(nextShutdown);
                            }
                        }
                    }
                }
            } // For Loop
View Full Code Here

        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) {
                instance.setSchedulingEnabled(Boolean.TRUE);
            }
            instance.setAutoRecover(Boolean.TRUE);
        }
        handler().sendUpdateInstancesToWotaskds(startingInstances, activeHosts.allObjects());
        handler().sendStartInstancesToWotaskds(startingInstances, activeHosts.allObjects());
        boolean waiting = true;

        // wait until apps have started
        while (waiting) {
            handler().startReading();
            try {
                log("Checking for started instances");
                handler().getInstanceStatusForHosts(activeHosts.allObjects());
                boolean allStarted = true;
                for (MInstance instance : startingInstances) {
                    allStarted &= instance.isRunning_M();
                }
                if (allStarted) {
                    waiting = false;
                } else {
                    sleep(10 * 1000);
                }
            } finally {
                handler().endReading();
            }
        }
        log("Started instances sucessfully");

        // turn scheduling off
        for (MHost host : activeHosts) {
            NSArray<MInstance> currentInstances = activeInstancesByHost.objectForKey(host);
            for (MInstance instance : currentInstances) {
                if (useScheduling) {
                    instance.setSchedulingEnabled(Boolean.FALSE);
                }
                instance.setAutoRecover(Boolean.FALSE);
            }
        }

        handler().sendUpdateInstancesToWotaskds(runningInstances, activeHosts.allObjects());

        // then start to refuse new sessions
        for (MHost host : activeHosts) {
            NSArray<MInstance> currentInstances = activeInstancesByHost.objectForKey(host);
            for (MInstance instance : currentInstances) {
                instance.setRefusingNewSessions(true);
            }
        }
        handler().sendRefuseSessionToWotaskds(runningInstances, activeHosts.allObjects(), true);
        log("Refused new sessions: " + runningInstances);

        // turn scheduling on again, but only
        NSMutableArray<MInstance> restarting = new NSMutableArray<MInstance>();
        for (MHost host : activeHosts) {
            NSArray<MInstance> currentInstances = activeInstancesByHost.objectForKey(host);
            for (int i = 0; i < currentInstances.count() - numToStartPerHost; i++) {
                MInstance instance = currentInstances.objectAtIndex(i);
                if (useScheduling) {
                    instance.setSchedulingEnabled(Boolean.TRUE);
                }
                instance.setAutoRecover(Boolean.TRUE);
                restarting.addObject(instance);
            }
        }
        handler().sendUpdateInstancesToWotaskds(restarting, activeHosts.allObjects());
        log("Started scheduling again: " + restarting);
View Full Code Here

    NSMutableArray<MInstance> startingInstances = new NSMutableArray<MInstance>();
        for (int i = 0; i < numInstancesToStartPerHost; i++) {
            for (MHost host : activeHosts) {
                NSArray<MInstance> inactiveInstancesForHost = MInstance.HOST.eq(host).filtered(inactiveInstances);
                if (inactiveInstancesForHost != null && inactiveInstancesForHost.count() >= i) {
                    MInstance instance = inactiveInstancesForHost.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());
                }
            }
View Full Code Here

        }
        cleanup();
    }

    public void clearDeaths(NSArray nsarray) {
        MInstance minstance;
        for (Enumeration enumeration = nsarray.objectEnumerator(); enumeration.hasMoreElements(); ) {
            minstance = (MInstance) enumeration.nextElement();
            processedInstance(minstance);
        }
        sendCommandInstancesToWotaskds("CLEAR");
View Full Code Here

    }

    public void scheduleType(NSArray nsarray, String scheduleType) {
        // Should be one of "HOURLY", "DAILY", "WEEKLY"
    for(Enumeration enumeration = nsarray.objectEnumerator(); enumeration.hasMoreElements();) {
      MInstance minstance = (MInstance) enumeration.nextElement();
      minstance.setSchedulingType(scheduleType);
      processedInstance(minstance);
    }
    sendUpdateInstancesToWotaskds();
    }
View Full Code Here

    public void hourlyStartHours(NSArray nsarray, int beginScheduleWindow, int endScheduleWindow, int interval) {
        int hour = beginScheduleWindow;
        for(Enumeration enumeration = nsarray.objectEnumerator(); enumeration.hasMoreElements();) {
          if (hour > endScheduleWindow)
            hour = beginScheduleWindow;
          MInstance minstance = (MInstance) enumeration.nextElement();
          minstance.setSchedulingHourlyStartTime(Integer.valueOf(hour));
          minstance.setSchedulingInterval(Integer.valueOf(interval));
          processedInstance(minstance);
          hour++;
        }
        sendUpdateInstancesToWotaskds();
    }
View Full Code Here

TOP

Related Classes of com.webobjects.monitor._private.MInstance

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.