01: /*
02:
03: * <copyright>
04: *
05: * Copyright 2002-2007 BBNT Solutions, LLC
06: * under sponsorship of the Defense Advanced Research Projects
07: * Agency (DARPA).
08: *
09: * You can redistribute this software and/or modify it under the
10: * terms of the Cougaar Open Source License as published on the
11: * Cougaar Open Source Website (www.cougaar.org).
12: *
13: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
14: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
16: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
17: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24: *
25: * </copyright>
26:
27: */
28:
29: package org.cougaar.qos.qrs;
30:
31: /**
32: * A ResourceContext for a Process which is on a Host. For now the Process named
33: * by its port, but latter it needs to have a list of ports and a PID. The
34: * available formulae ???
35: */
36: public class ProcessDS extends ResourceContext {
37: static void register() {
38: ContextInstantiater cinst = new AbstractContextInstantiater() {
39: public ResourceContext instantiateContext(
40: String[] parameters, ResourceContext parent)
41: throws ResourceContext.ParameterError {
42: return new ProcessDS(parameters, parent);
43: }
44:
45: };
46: registerContextInstantiater("Process", cinst);
47: }
48:
49: private static final String PID = "pid";
50: private static final String PORT = "port";
51:
52: protected DataFormula instantiateFormula(String kind) {
53: return null;
54: }
55:
56: /**
57: * The parameters should contain one string, the port of the host being
58: * monitored.
59: */
60: protected void verifyParameters(String[] parameters)
61: throws ParameterError {
62: if (parameters == null || parameters.length != 1) {
63: throw new ParameterError(
64: "ProcessDS: wrong number of parameters");
65: } else {
66: String port_string = parameters[0];
67: try {
68: int port = Integer.parseInt(port_string);
69: bindSymbolValue(PORT, port);
70:
71: // To be done
72: bindSymbolValue(PID, 0);
73: } catch (NumberFormatException not_a_num) {
74: throw new ParameterError(
75: "ProcessDS: port is not an int");
76: }
77: }
78:
79: }
80:
81: private ProcessDS(String[] parameters, ResourceContext parent)
82: throws ParameterError {
83: super (parameters, parent);
84: }
85:
86: // Some Day Process will have formulas to calculate things like
87: // nice value.
88:
89: }
|