Package com.webobjects.monitor._private

Examples of com.webobjects.monitor._private.MHost


                                    .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

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

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

    sendUpdateInstancesToWotaskds();
}

    public void turnScheduledOn(NSArray nsarray) {
        for(Enumeration enumeration = nsarray.objectEnumerator(); enumeration.hasMoreElements();) {
            MInstance minstance = (MInstance) enumeration.nextElement();
            if (!minstance.isScheduled()) {
                minstance.setSchedulingEnabled(Boolean.TRUE);
                processedInstance(minstance);
            }
        }
        sendUpdateInstancesToWotaskds();
    }
View Full Code Here

        sendUpdateInstancesToWotaskds();
    }

    public void turnScheduledOff(NSArray nsarray) {
        for(Enumeration enumeration = nsarray.objectEnumerator(); enumeration.hasMoreElements();) {
            MInstance minstance = (MInstance) enumeration.nextElement();
            if (minstance.isScheduled()) {
                minstance.setSchedulingEnabled(Boolean.FALSE);
                processedInstance(minstance);
            }
        }
        sendUpdateInstancesToWotaskds();
    }
View Full Code Here

TOP

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

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.