001: // serverSwitch.java
002: // -------------------------------------------
003: // (C) by Michael Peter Christen; mc@anomic.de
004: // first published on http://www.anomic.de
005: // Frankfurt, Germany, 2004
006: //
007: // $LastChangedDate: 2008-01-31 23:40:47 +0000 (Do, 31 Jan 2008) $
008: // $LastChangedRevision: 4424 $
009: // $LastChangedBy: orbiter $
010: //
011: // This program is free software; you can redistribute it and/or modify
012: // it under the terms of the GNU General Public License as published by
013: // the Free Software Foundation; either version 2 of the License, or
014: // (at your option) any later version.
015: //
016: // This program is distributed in the hope that it will be useful,
017: // but WITHOUT ANY WARRANTY; without even the implied warranty of
018: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
019: // GNU General Public License for more details.
020: //
021: // You should have received a copy of the GNU General Public License
022: // along with this program; if not, write to the Free Software
023: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024: //
025: // Using this software in any meaning (reading, learning, copying, compiling,
026: // running) means that you agree that the Author(s) is (are) not responsible
027: // for cost, loss of data or any harm that may be caused directly or indirectly
028: // by usage of this softare or this documentation. The usage of this software
029: // is on your own risk. The installation and usage (starting/running) of this
030: // software may allow other people or application to access your computer and
031: // any attached devices and is highly dependent on the configuration of the
032: // software which must be done by the user of the software; the author(s) is
033: // (are) also not responsible for proper configuration and usage of the
034: // software, even if provoked by documentation provided together with
035: // the software.
036: //
037: // Any changes to this file according to the GPL as documented in the file
038: // gpl.txt aside this file in the shipment you received can be done to the
039: // lines that follows this copyright notice here, but changes must not be
040: // done inside the copyright notive above. A re-distribution must contain
041: // the intact and unchanged copyright notice.
042: // Contributions and changes to the program code must be marked as such.
043:
044: /*
045: this is an interface for possible switchboard implementations
046: Its purpose is to provide a mechanism which cgi pages can use
047: to influence the behavior of a concurrntly running application
048: */
049:
050: package de.anomic.server;
051:
052: import java.io.File;
053: import java.net.InetAddress;
054: import java.util.Iterator;
055: import java.util.Map;
056: import java.util.TreeMap;
057:
058: import de.anomic.server.logging.serverLog;
059:
060: public interface serverSwitch {
061:
062: // the root path for the application
063: public File getRootPath();
064:
065: // a logger for this switchboard
066: public void setLog(serverLog log);
067:
068: public serverLog getLog();
069:
070: // access tracker
071: public void track(String host, String accessPath); // learn that a specific host has accessed a specific path
072:
073: public TreeMap<Long, String> accessTrack(String host); // returns mapping from Long(accesstime) to path
074:
075: public Iterator<String> accessHosts(); // returns an iterator of hosts in tracker (String)
076:
077: // a switchboard can have action listener
078: // these listeners are hooks for numerous methods below
079: public void deployAction(String actionName,
080: String actionShortDescription,
081: String actionLongDescription, serverSwitchAction action);
082:
083: public void undeployAction(String actionName);
084:
085: // the switchboard can manage worker threads
086: public void deployThread(String threadName,
087: String threadShortDescription,
088: String threadLongDescription, String threadMonitorURL,
089: serverThread newThread, long startupDelay,
090: long initialIdleSleep, long initialBusySleep,
091: long initialMemoryPreRequisite);
092:
093: public serverThread getThread(String threadName);
094:
095: public void setThreadPerformance(String threadName,
096: long idleMillis, long busyMillis, long memprereq);
097:
098: public void terminateThread(String threadName, boolean waitFor);
099:
100: public void intermissionAllThreads(long pause);
101:
102: public void terminateAllThreads(boolean waitFor);
103:
104: public Iterator<String> /*of serverThread-Names (String)*/threadNames();
105:
106: // the switchboard can be used to set and read properties
107: public void setConfig(Map<String, String> otherConfigs);
108:
109: public void setConfig(String key, long value);
110:
111: public void setConfig(String key, String value);
112:
113: public String getConfig(String key, String dflt);
114:
115: public long getConfigLong(String key, long dflt);
116:
117: public boolean getConfigBool(String key, boolean dflt);
118:
119: public File getConfigPath(String key, String dflt);
120:
121: public Iterator<String> configKeys();
122:
123: public Map<String, String> getRemoved();
124:
125: // the switchboard also shall maintain a job list
126: // jobs can be queued by submitting a job object
127: // to work off a queue job, use deQueue, which is meant to
128: // work off exactly only one job, not all
129: public int queueSize();
130:
131: public void enQueue(Object job);
132:
133: public boolean deQueue(); // returns true if there had been dequeued anything
134:
135: // authentification routines: sets and reads access attributes according to host addresses
136: public void setAuthentify(InetAddress host, String user,
137: String rigth);
138:
139: public void removeAuthentify(InetAddress host);
140:
141: public String getAuthentifyUser(InetAddress host);
142:
143: public String getAuthentifyRights(InetAddress host);
144:
145: public void addAuthentifyRight(InetAddress host, String right);
146:
147: public boolean hasAuthentifyRight(InetAddress host, String right);
148:
149: // ask the switchboard to perform an action
150: // the result is a properties structure with the result of the action
151: // The actionName selects an action
152: // the actionInput is an input for the selected action
153: public serverObjects action(String actionName,
154: serverObjects actionInput);
155:
156: // performance control: the server can announce busy and idle status to the switchboard
157: // these announcements can be used to trigger events or interrupts
158: public void handleBusyState(int jobs);
159:
160: }
|