Package com.webobjects.monitor._private

Examples of com.webobjects.monitor._private.MSiteConfig


    public WOActionResults defaultAction() {
        // KH - make this faster as well :)
        Application theApplication = (Application) WOApplication.application();
        WOResponse aResponse = theApplication.createResponseInContext(null);
        WORequest aRequest = request();
        MSiteConfig aConfig = theApplication.siteConfig();

        theApplication._lock.startReading();
        try {

            // Check for correct password
            String passwordHeader = aRequest.headerForKey("password");
            if (!aConfig.comparePasswordWithPassword(passwordHeader)) {
                NSLog.debug.appendln("Attempt to call Direct Action: defaultAction with incorrect password.");
                aResponse.setStatus(WOMessage.HTTP_STATUS_FORBIDDEN);
                aResponse.appendContentString("Attempt to call Direct Action: defaultAction on wotaskd with incorrect password.");
                // we endReading at the finally block
                return aResponse;
            }

            aResponse.appendContentString("<html><head><title>Wotaskd for WebObjects 5</title></head><body>");
            aResponse.appendContentString("<center><b>Wotaskd for WebObjects 5: " + _hostName + "</b></center>");
            aResponse.appendContentString("<br><br><hr><br>Site Config as written to disk<br><hr><br><pre>");
            aResponse.appendContentString(WOMessage.stringByEscapingHTMLString(aConfig.generateSiteConfigXML()));
            aResponse.appendContentString("</pre><br><br><hr><br>Adaptor Config as sent to Local WOAdaptors - All Running Applications and Instances<br><hr><br><pre>");
            aResponse.appendContentString(WOMessage.stringByEscapingHTMLString(aConfig.generateAdaptorConfigXML(true, true)));
            aResponse.appendContentString("</pre><br><br><br><br>Adaptor Config as sent to remote WOAdaptors - All Registered and Running Applications and Instances<br><hr><br><pre>");
            aResponse.appendContentString(WOMessage.stringByEscapingHTMLString(aConfig.generateAdaptorConfigXML(true, false)));
            aResponse.appendContentString("</pre><br><br><hr><br>Adaptor Config as written to disk - All Registered Applications and Instances<br><hr><br><pre>");
            aResponse.appendContentString(WOMessage.stringByEscapingHTMLString(aConfig.generateAdaptorConfigXML(false, false)));
            aResponse.appendContentString("</pre><br><br><hr><br>Properties of this wotaskd<br><hr><br><pre>");

            aResponse.appendContentString("The Configuration Directory is: " + MSiteConfig.configDirectoryPath());
            aResponse.appendContentString("<br>");
            if (((Application)WOApplication.application()).shouldWriteAdaptorConfig()) {
View Full Code Here


  public WOActionResults updateAction() throws Throwable {
    checkPassword();
    if (siteConfig().hostArray().count() == 0) {
      throw new IllegalStateException("You cannot update the SiteConfig before adding a host.");
    }
    MSiteConfig siteConfig = (MSiteConfig) object(ERXKeyFilter.filterWithAttributes());
    update(siteConfig, ERXKeyFilter.filterWithAttributes());
    pushValues(siteConfig);
    return response(siteConfig, ERXKeyFilter.filterWithAttributes());
  }
View Full Code Here

import er.rest.ERXRestContext;

public class MSiteConfigRestDelegate extends JavaMonitorRestDelegate {
 
  public Object createObjectOfEntityWithID(EOClassDescription entity, Object id, ERXRestContext context) {
    return new MSiteConfig(null);
  }
View Full Code Here

    final int _receiveTimeout = ERXProperties.intForKeyWithDefault("WOTaskd.receiveTimeout", 5000);
    final boolean _forceQuitTaskEnabled = ERXProperties.booleanForKeyWithDefault("WOTaskd.forceQuitTaskEnabled", false);


    public LocalMonitor() {
        MSiteConfig aConfig = theApplication.siteConfig();

        if (System.getProperties().getProperty("os.name").toLowerCase().startsWith("win")) {
            _isOnWindows = true;
        }
        _shouldUseSpawn = String_Extensions.boolValue(System.getProperty("WOShouldUseSpawn"));
        if (_shouldUseSpawn) {
            String appDir = System.getProperties().getProperty("user.dir");
            appDir = NSPathUtilities.stringByAppendingPathComponent(appDir, "Contents");
            appDir = NSPathUtilities.stringByAppendingPathComponent(appDir, "Resources");
            if (_isOnWindows)
                appDir = NSPathUtilities.stringByAppendingPathComponent(appDir, "SpawnOfWotaskd.exe");
            else
                appDir = NSPathUtilities.stringByAppendingPathComponent(appDir, "SpawnOfWotaskd.sh");

            spawningGrounds = appDir + " ";

            File theApp = new File(appDir);

            if (!(theApp.exists() && theApp.isFile())) {
                _shouldUseSpawn = false;
            }
        }

        // Used to do phased startup the first time startup
        anAutoRecoverStartupTimer = WOTimer.scheduledTimer(aConfig.autoRecoverInterval(), this, "_checkAutoRecoverStartup", null, null, false);

        _hostName = theApplication.host();
    }
View Full Code Here

    public void _checkAutoRecoverStartup() {
        if (NSLog.debugLoggingAllowedForLevelAndGroups(NSLog.DebugLevelDetailed, NSLog.DebugGroupDeployment))
            NSLog.debug.appendln("_checkAutoRecoverStartup START");
        theApplication._lock.startReading();
        try {
            MSiteConfig aConfig = theApplication.siteConfig();
            final NSArray appArray = aConfig.applicationArray();
            int appArrayCount = appArray.count();
            final LocalMonitor localMonitor = this;

            Thread[] workers = new Thread[appArrayCount];

            for (int i=0; i<workers.length; i++) {
                final int j = i;
                Runnable work = new Runnable() {
                    public void run() {
                        localMonitor._autoRecoverApplication((MApplication) appArray.objectAtIndex(j));
                    }
                };
                workers[j] = new Thread(work);
                workers[j].start();
            }

            try {
                for (int i=0; i<workers.length; i++) {
                    workers[i].join();
                }
            } catch (InterruptedException ie) {}

            // That timer will kick off a repeating, hourly, timer for _checkSchedules every hour on the hour
            NSTimestamp fireDate = calculateNearestHour();

            //NSTimestamp fireDate, long ti, Object aTarget, String aSelectorName, Object userInfo, Class userInfoClass, boolean repeat
            aScheduleTimer = new WOTimer(fireDate, (60 * 60 * 1000), this, "_checkSchedules", null, null, true);
            aScheduleTimer.schedule();

            // This is the regular timer that should do autorecovery
            anAutoRecoverTimer = WOTimer.scheduledTimer(aConfig.autoRecoverInterval(), this, "_checkAutoRecover", null, null, true);

        } finally {
            theApplication._lock.endReading();
        }
        if (NSLog.debugLoggingAllowedForLevelAndGroups(NSLog.DebugLevelDetailed, NSLog.DebugGroupDeployment))
View Full Code Here

    /********** Controlling Instances **********/
    // Returns null if success
    @Override
    public String startInstance(MInstance anInstance) {
        MSiteConfig aConfig = theApplication.siteConfig();
        if (anInstance == null)
            return "Attempt to start null instance on " + _hostName;
        if (anInstance.host() != aConfig.localHost())
            return anInstance.displayName() + " does not exist on " + _hostName + "; START instance failed";
        if (anInstance.isRunning_W())
            //            return _hostName + ": " + anInstance.displayName() + " is already running";
            return null;
        if (anInstance.state == MObject.STARTING)
View Full Code Here

        NSDictionary xmlDict = createInstanceRequestDictionary(null, "STATISTICS", anInstance);
        return sendInstanceRequest(anInstance, xmlDict);
    }

    protected void catchInstanceErrors(MInstance anInstance) throws MonitorException {
        MSiteConfig aConfig = theApplication.siteConfig();
        if (anInstance == null)
            throw new MonitorException("Attempt to command null instance on " + _hostName);
        if (anInstance.host() != aConfig.localHost())
            throw new MonitorException(anInstance.displayName() + " does not exist on " + _hostName + "; command failed");
        if (!anInstance.isRunning_W())
            throw new MonitorException(_hostName + ": " + anInstance.displayName() + " is not running");
    }
View Full Code Here

    }

    @Override
    public void appendToResponse(WOResponse aResponse, WOContext aContext) {
        // Check to make sure they have logged in if it is required
        MSiteConfig aMonitorConfig = siteConfig();

        if ((aMonitorConfig == null) || (aMonitorConfig.isPasswordRequired())) {
            if (_isLoggedIn) {
                super.appendToResponse(aResponse, aContext);
            } else {
                if (aContext.page().getClass().getName().equals(Main.class.getName())) {
                    // needs to login on Main page.
View Full Code Here

    if (responseContent != null) {
      byte[] responseContentBytes = responseContent.bytes();
      String responseContentString = new String(responseContentBytes);

      if (responseContentString.startsWith("ERROR")) {
        throw new MonitorException("Path " + thePath + " does not exist");
      }

      _JavaMonitorDecoder aDecoder = new _JavaMonitorDecoder();
      try {
        byte[] evilHackCombined = new byte[responseContentBytes.length + evilHack.length];
        // System.arraycopy(src, src_pos, dst, dst_pos, length);
        System.arraycopy(evilHack, 0, evilHackCombined, 0, evilHack.length);
        System.arraycopy(responseContentBytes, 0, evilHackCombined, evilHack.length,
            responseContentBytes.length);
        anArray = (NSArray) aDecoder.decodeRootObject(new NSData(evilHackCombined));
      } catch (WOXMLException wxe) {
        NSLog.err.appendln("RemoteBrowseClient _getFileListOutOfResponse Error decoding response: "
            + responseContentString);
        throw new MonitorException("Host returned bad response for path " + thePath);
      }

    } else {
      NSLog.err.appendln("RemoteBrowseClient _getFileListOutOfResponse Error decoding null response");
      throw new MonitorException("Host returned null response for path " + thePath);
    }

    String isRoots = aResponse.headerForKey("isRoots");
    String filepath = aResponse.headerForKey("filepath");
View Full Code Here

      if (requestSucceeded) {
        aResponse = anHTTPConnection.readResponse();
      }

      if ((aResponse == null) || (!requestSucceeded) || (aResponse.status() != 200)) {
        throw new MonitorException("Error requesting directory listing for " + aString + " from " + aHost.name());
      }

      try {
        aFileListDictionary = _getFileListOutOfResponse(aResponse, aString);
      } catch (MonitorException me) {
        if (NSLog
            .debugLoggingAllowedForLevelAndGroups(NSLog.DebugLevelCritical, NSLog.DebugGroupDeployment))
          NSLog.debug.appendln("caught exception: " + me);
        throw me;
      }

      aHost.isAvailable = true;
    } catch (MonitorException me) {
      aHost.isAvailable = true;
      throw me;
    } catch (Exception localException) {
      aHost.isAvailable = false;
      NSLog.err.appendln("Exception requesting directory listing: ");
      localException.printStackTrace();
      throw new MonitorException("Exception requesting directory listing for " + aString + " from "
          + aHost.name() + ": " + localException.toString());
    }
    return aFileListDictionary;
  }
View Full Code Here

TOP

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

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.