perfsonar-dev - perfsonar: r3221 - in trunk/geant2_java-sshtelnet-mp: conf/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters samples src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters
Subject: perfsonar development work
List archive
perfsonar: r3221 - in trunk/geant2_java-sshtelnet-mp: conf/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters samples src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters
Chronological Thread
- From:
- To:
- Subject: perfsonar: r3221 - in trunk/geant2_java-sshtelnet-mp: conf/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters samples src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters
- Date: Mon, 14 Jan 2008 08:33:00 -0500
Author: melis
Date: 2008-01-14 08:32:59 -0500 (Mon, 14 Jan 2008)
New Revision: 3221
Added:
trunk/geant2_java-sshtelnet-mp/samples/sshtelnetmptemplate.csv
Modified:
trunk/geant2_java-sshtelnet-mp/conf/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.class
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.java
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/WebserviceEngineAdapter.java
Log:
added ongoing development:
- added two new parameters to the metadataconfiguration
- added implementation for "maximumnumberofusers" (but it still needs to be
tested)
Modified:
trunk/geant2_java-sshtelnet-mp/conf/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.class
===================================================================
(Binary files differ)
Added: trunk/geant2_java-sshtelnet-mp/samples/sshtelnetmptemplate.csv
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.java
2008-01-14 13:23:38 UTC (rev 3220)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/ServicePropertiesConfigurator.java
2008-01-14 13:32:59 UTC (rev 3221)
@@ -158,11 +158,11 @@
String deviceType;
//String[] devicesArray = new String[lines.length];
- //System.out.println("[DEBUG] number of lines to be parsed: " +
lines.length);
+ System.out.println("[DEBUG] number of lines to be parsed: " +
lines.length);
for (int i = 0; i < lines.length && lines[i] != null; i++) {
- //System.out.println("[DEBUG] line: "+lines[i]);
+ System.out.println("[DEBUG] line: "+lines[i]);
metadata = new Element("metadata", NMWG);
metadata.setAttribute("id", "metadata" + i);
@@ -217,6 +217,14 @@
param.setAttribute("value", "" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
params.addContent(param);
param = new Element("parameter", NMWG);
+ param.setAttribute("name", "timeout");
+ param.setAttribute("value", "" + deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter", NMWG);
+ param.setAttribute("name", "numberOfUsers");
+ param.setAttribute("value", "" + deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter", NMWG);
param.setAttribute("name", "cache");
param.setAttribute("value", "0");
params.addContent(param);
@@ -252,6 +260,14 @@
param.setAttribute("value", "" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
params.addContent(param);
param = new Element("parameter", NMWG);
+ param.setAttribute("name", "timeout");
+ param.setAttribute("value", "" + deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter", NMWG);
+ param.setAttribute("name", "numberOfUsers");
+ param.setAttribute("value", "" + deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter", NMWG);
param.setAttribute("name", "cache");
param.setAttribute("value", "0");
params.addContent(param);
@@ -286,6 +302,14 @@
param.setAttribute("name", "keyUrl");
param.setAttribute("value", "" + deviceTok.nextToken());
params.addContent(param);
+ param = new Element("parameter", NMWG);
+ param.setAttribute("name", "timeout");
+ param.setAttribute("value", "" + deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter", NMWG);
+ param.setAttribute("name", "numberOfUsers");
+ param.setAttribute("value", "" + deviceTok.nextToken());
+ params.addContent(param);
if (deviceTok.hasMoreTokens()) {
param = new Element("parameter", NMWG);
param.setAttribute("name", "passphrase");
@@ -328,6 +352,14 @@
param.setAttribute("value", "" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
params.addContent(param);
param = new Element("parameter", NMWG);
+ param.setAttribute("name", "timeout");
+ param.setAttribute("value", "" + deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter", NMWG);
+ param.setAttribute("name", "numberOfUsers");
+ param.setAttribute("value", "" + deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter", NMWG);
param.setAttribute("name", "cache");
param.setAttribute("value", "0");
params.addContent(param);
@@ -363,6 +395,14 @@
param.setAttribute("value", "" +
PasswordEncryptor.encryptPassword(deviceTok.nextToken()));
params.addContent(param);
param = new Element("parameter", NMWG);
+ param.setAttribute("name", "timeout");
+ param.setAttribute("value", "" + deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter", NMWG);
+ param.setAttribute("name", "numberOfUsers");
+ param.setAttribute("value", "" + deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter", NMWG);
param.setAttribute("name", "cache");
param.setAttribute("value", "0");
params.addContent(param);
@@ -397,6 +437,14 @@
param.setAttribute("name", "keyUrl");
param.setAttribute("value", "" + deviceTok.nextToken());
params.addContent(param);
+ param = new Element("parameter", NMWG);
+ param.setAttribute("name", "timeout");
+ param.setAttribute("value", "" + deviceTok.nextToken());
+ params.addContent(param);
+ param = new Element("parameter", NMWG);
+ param.setAttribute("name", "numberOfUsers");
+ param.setAttribute("value", "" + deviceTok.nextToken());
+ params.addContent(param);
if (deviceTok.hasMoreTokens()) {
param = new Element("parameter", NMWG);
param.setAttribute("name", "passphrase");
@@ -449,6 +497,8 @@
*/
} catch (IOException e) {
e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
@@ -498,7 +548,7 @@
if (devices.size() > 0) {
Iterator it = devices.iterator();
- System.out.println(devices.size() + " devices added.");
+ System.out.println("****" + devices.size() + " devices
added.");
System.out.println("");
System.out.println("Choose one of the following types of
equipment for every ");
@@ -600,6 +650,19 @@
params.addContent(param);
System.out.println("Please give the port for device:
" + device + ": ");
input = br.readLine();
+ boolean valid = false;
+ while (!valid){
+ try {
+ if (Integer.parseInt(input) < 0) {
+ System.out.println("Please
provide a positive number.");
+ input = br.readLine();
+ }
+ else valid = true;
+ } catch (NumberFormatException nfe) {
+ System.out.println("Please provide a
positive number.");
+ input = br.readLine();
+ }
+ }
param = new Element("parameter", NMWG);
param.setAttribute("name", "port");
param.setAttribute("value", input);
@@ -612,6 +675,19 @@
params.addContent(param);
System.out.println("Please give the access rate for
device (in ms): " + device + ": ");
input = br.readLine();
+ valid = false;
+ while (!valid){
+ try {
+ if (Integer.parseInt(input) < 0){
+ System.out.println("Please
provide a positive number.");
+ input = br.readLine();
+ }
+ else valid = true;
+ } catch (NumberFormatException nfe) {
+ System.out.println("Please provide a
positive number.");
+ input = br.readLine();
+ }
+ }
param = new Element("parameter", NMWG);
param.setAttribute("name", "rate");
param.setAttribute("value", input);
@@ -639,7 +715,46 @@
param.setAttribute("value",
PasswordEncryptor.encryptPassword(input));
params.addContent(param);
+ System.out.println("Please give the timeout for the
device: " + device + "(enter 0 if you don't want to use a timeout): ");
+ input = br.readLine();
+ valid = false;
+ while (!valid){
+ try {
+ if (Integer.parseInt(input) < 0){
+ System.out.println("Please
provide a positive number.");
+ input = br.readLine();
+ }
+ else valid = true;
+ } catch (NumberFormatException nfe) {
+ System.out.println("Please provide a
positive number.");
+ input = br.readLine();
+ }
+ }
param = new Element("parameter", NMWG);
+ param.setAttribute("name", "timeout");
+ param.setAttribute("value", input);
+ params.addContent(param);
+ System.out.println("Please give the maximum number
of users for the device: " + device + "(enter 0 if you want an unlimited
amount of users): ");
+ input = br.readLine();
+ valid = false;
+ while (!valid){
+ try {
+ if (Integer.parseInt(input) < 0){
+ System.out.println("Please
provide a positive number.");
+ input = br.readLine();
+ }
+ else valid = true;
+ } catch (NumberFormatException nfe) {
+ System.out.println("Please provide a
positive number.");
+ input = br.readLine();
+ }
+ }
+ param = new Element("parameter", NMWG);
+ param.setAttribute("name", "numberOfUsers");
+ param.setAttribute("value", "" + input);
+ params.addContent(param);
+
+ param = new Element("parameter", NMWG);
param.setAttribute("name", "cache");
param.setAttribute("value", "0");
params.addContent(param);
@@ -669,6 +784,19 @@
params.addContent(param);
System.out.println("Please give the port for device:
" + device + ": ");
input = br.readLine();
+ boolean valid = false;
+ while (!valid){
+ try {
+ if (Integer.parseInt(input) < 0){
+ System.out.println("Please
provide a positive number.");
+ input = br.readLine();
+ }
+ else valid = true;
+ } catch (NumberFormatException nfe) {
+ System.out.println("Please provide a
positive number.");
+ input = br.readLine();
+ }
+ }
param = new Element("parameter", NMWG);
param.setAttribute("name", "port");
param.setAttribute("value", input);
@@ -681,6 +809,19 @@
params.addContent(param);
System.out.println("Please give the access rate for
device (in ms): " + device + ": ");
input = br.readLine();
+ valid = false;
+ while (!valid){
+ try {
+ if (Integer.parseInt(input) < 0){
+ System.out.println("Please
provide a positive number.");
+ input = br.readLine();
+ }
+ else valid = true;
+ } catch (NumberFormatException nfe) {
+ System.out.println("Please provide a
positive number.");
+ input = br.readLine();
+ }
+ }
param = new Element("parameter", NMWG);
param.setAttribute("name", "rate");
param.setAttribute("value", input);
@@ -719,7 +860,46 @@
}
+ System.out.println("Please give the timeout for the
device: " + device + "(enter 0 if you don't want to use a timeout): ");
+ input = br.readLine();
+ valid = false;
+ while (!valid){
+ try {
+ if (Integer.parseInt(input) < 0){
+ System.out.println("Please
provide a positive number.");
+ input = br.readLine();
+ }
+ else valid = true;
+ } catch (NumberFormatException nfe) {
+ System.out.println("Please provide a
positive number.");
+ input = br.readLine();
+ }
+ }
param = new Element("parameter", NMWG);
+ param.setAttribute("name", "timeout");
+ param.setAttribute("value", input);
+ params.addContent(param);
+ System.out.println("Please give the maximum number
of users for the device: " + device + "(enter 0 if you want an unlimited
amount of users): ");
+ input = br.readLine();
+ valid = false;
+ while (!valid){
+ try {
+ if (Integer.parseInt(input) < 0){
+ System.out.println("Please
provide a positive number.");
+ input = br.readLine();
+ }
+ else valid = true;
+ } catch (NumberFormatException nfe) {
+ System.out.println("Please provide a
positive number.");
+ input = br.readLine();
+ }
+ }
+ param = new Element("parameter", NMWG);
+ param.setAttribute("name", "numberOfUsers");
+ param.setAttribute("value", "" + input);
+ params.addContent(param);
+
+ param = new Element("parameter", NMWG);
param.setAttribute("name", "cache");
param.setAttribute("value", "0");
params.addContent(param);
@@ -812,15 +992,25 @@
System.out.println("Select which BGP-commands
you wish to be supported:");
selectCommands("cisco", "bgp",
tempFile.toString());
+ //System.out.println("[DEBUG] Commands
Selected");
+
data = new Element("data", NMWG);
data.setAttribute("id", "data" + index);
data.setAttribute("metadataIdRef", "metadata" +
index);
+ //System.out.println("[DEBUG] XML elements
created");
+
addSelectedCommandsToConfig(device, outputFile,
tempFile.toString());
+ //System.out.println("[DEBUG] Selected commands
added to configfile");
+
store.addContent(data);
+ //System.out.println("[DEBUG] data XML element
added to root element");
+
tempFile.delete();
+
+ //System.out.println("[DEBUG] temporary file
deleted");
} else if (type.equalsIgnoreCase("4") ||
type.equalsIgnoreCase("5") || type.equalsIgnoreCase("6")) { // Juniper device
File tempFile =
File.createTempFile("ciscominimum", ".tmp");
System.out.println("\nFirst you can choose which
IP-commands you wish to be supported:");
@@ -832,19 +1022,30 @@
System.out.println("Select which BGP-commands
you wish to be supported:");
selectCommands("juniper", "bgp",
tempFile.toString());
+ //System.out.println("[DEBUG] Commands
Selected");
+
data = new Element("data", NMWG);
data.setAttribute("id", "data" + index);
data.setAttribute("metadataIdRef", "metadata" +
index);
+ //System.out.println("[DEBUG] XML elements
created");
+
addSelectedCommandsToConfig(device, outputFile,
tempFile.toString());
+ //System.out.println("[DEBUG] Selected commands
added to configfile");
+
store.addContent(data);
+ //System.out.println("[DEBUG] data XML element
added to root element");
+
tempFile.delete();
+
+ //System.out.println("[DEBUG] temporary file
deleted");
} else { // Shouldn't happen
System.out.println("ERROR - Not a valid
device.");
}
}
+ //System.out.println("[DEBUG] There are more devices: "
+ it.hasNext());
}
}
} catch (IOException e) {
@@ -980,7 +1181,7 @@
br.close();
dos.close();
}
- System.out.println("\nChoosen commands temporarily saved to
file...\n");
+ //System.out.println("\n[DEBUG] Choosen commands temporarily
saved to file...\n");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException ioe) {
@@ -1101,7 +1302,7 @@
//System.out.println("[DEBUG] Number of keys inside the data
element: "+data.getChildren("key", NMWG).size());
input = br.readLine();
- //System.out.println("[DEBUG] Line read: " + input);
+ //System.out.println("[DEBUG] Line read: " + input);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
Modified:
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/WebserviceEngineAdapter.java
===================================================================
---
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/WebserviceEngineAdapter.java
2008-01-14 13:23:38 UTC (rev 3220)
+++
trunk/geant2_java-sshtelnet-mp/src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters/WebserviceEngineAdapter.java
2008-01-14 13:32:59 UTC (rev 3221)
@@ -47,8 +47,11 @@
*/
private String serviceEngineType = null;
private Message[] messages;
- private static int count = 0;
+ private static int[] count;
+ private long[] startTimes;
+ private long[] endTimes;
+
// ---------------------- class-fields
private LoggerComponent logger = null;
private MetadataConfiguration configuration = null;
@@ -72,6 +75,11 @@
devices =
configuration.getProperties(MetadataConfiguration.DEVICE_NAMES);
registerServiceWithLS();
+
+ count = new int[devices.size()];
+
+ for (int i = 0; i < count.length; i++)
+ count[i] = 0;
} catch (PerfSONARException e) {
@@ -101,8 +109,6 @@
logger.info("[WebserviceEngineAdapter] Webservice takeAction call
received");
- logger.info("COUNT: " + count++);
-
Metadata[] requestMetadata = request.getMetadataArray();
Data[] requestData = request.getDataArray();
@@ -119,6 +125,10 @@
RequestMonitor requestMonitor = new RequestMonitor(
requestMetadata.length);
+ int[] currentDevices = new int[requestMetadata.length];
+ for (int i = 0; i < currentDevices.length; i++)
+ currentDevices[i] = -1;
+
for (int i = 0; i < requestMetadata.length; i++) {
Subject subjectTemp = requestMetadata[i].getSubject();
boolean deviceElementOK = true;
@@ -133,25 +143,72 @@
if (deviceElementOK && devices.contains(value)) {
- Message message = new Message();
- message.setMetadata(requestMetadata[i]);
- String metadataIdRef = requestMetadata[i].getId();
+ count[devices.indexOf(value)]++;
+ currentDevices[i] = devices.indexOf(value);
//contains the indexes of the devices in use
+ logger.debug("Number of current connections for
device \"" + value + "\": " + count[devices.indexOf(value)]);
+
+ if (count[devices.indexOf(value)] <=
Integer.parseInt(configuration.getProperty(value, "numberOfUsers"))){
+
+ Message message = new Message();
+ message.setMetadata(requestMetadata[i]);
+ String metadataIdRef = requestMetadata[i].getId();
+
+ for (int j = 0; j < requestData.length; j++) {
+ if
(requestData[j].getMetadataIdRef().equalsIgnoreCase(
+ metadataIdRef)) {
+ message.setData(requestData[j]);
+ }
+ }
+
+ String serviceEngineString =
configuration.getProperty(value, "class_name");
+
+ RequestExecutingThread requestExecutingThread =
new RequestExecutingThread(
+ i, actionType, serviceEngineString,
message,
+ requestMetadata[i], requestMonitor);
+
+ requestExecutingThread.start();
+ } else {
+ messages[i] = new Message();
+ messages[i].setMetadata(requestMetadata[i]);
+ String metadataIdRef = requestMetadata[i].getId();
- for (int j = 0; j < requestData.length; j++) {
- if
(requestData[j].getMetadataIdRef().equalsIgnoreCase(
- metadataIdRef)) {
- message.setData(requestData[j]);
+ for (int j = 0; j < requestData.length; j++) {
+ if
(requestData[j].getMetadataIdRef().equalsIgnoreCase(
+ metadataIdRef)) {
+ messages[i].setData(requestData[j]);
+ }
}
- }
- String serviceEngineString =
configuration.getProperty(value, "class_name");
+ Metadata resultCodeMetadata = new Metadata();
+ resultCodeMetadata.setId("resultCodeMeta_" +
requestMetadata[i].getId());
- RequestExecutingThread requestExecutingThread = new
RequestExecutingThread(
- i, actionType, serviceEngineString, message,
- requestMetadata[i], requestMonitor);
+ Subject resultCodeSubject = new Subject();
+ resultCodeSubject.setId("resultCodeSubj_" +
requestMetadata[i].getId());
+
resultCodeSubject.setMetadataIdRef(requestMetadata[i].getId());
- requestExecutingThread.start();
+ EventType resultCodeEventType = new EventType();
+ resultCodeEventType.setId("resultCodeEventType_" +
requestMetadata[i].getId());
+
resultCodeEventType.setEventType("error.mp.sshtelnet.device");
+ resultCodeMetadata.addChild(resultCodeSubject);
+ resultCodeMetadata.addChild(resultCodeEventType);
+
+ Data resultCodeData = new Data();
+ resultCodeData.setId("resultCodeData_" +
requestMetadata[i].getId());
+ resultCodeData.setMetadataIdRef("resultCodeMeta_" +
requestMetadata[i].getId());
+
+ Datum resultCodeDatum = new Datum();
+ resultCodeDatum.setId("resultCodeDatum_" +
requestMetadata[i].getId());
+ resultCodeDatum.setValue("Too many concurrent
connections to the device. Please try again later.");
+
+ resultCodeData.addChild(resultCodeDatum);
+
+ messages[i].setMetadata(resultCodeMetadata);
+ messages[i].setData(resultCodeData);
+
+ requestMonitor.setCompleted(i, null);
+ }
+
} else {
messages[i] = new Message();
@@ -206,8 +263,8 @@
while (!requestMonitor.isCompleted()) {
try {
- Toolkit toolkit = Toolkit.getDefaultToolkit();
- toolkit.beep();
+ //Toolkit toolkit = Toolkit.getDefaultToolkit();
+ //toolkit.beep();
Thread.sleep(2000);
} catch (InterruptedException e) {
logger.error("[WEBSERVICEENGINEADAPTER][TakeAction]"+e.getStackTrace().toString());
@@ -234,7 +291,12 @@
}
}
-
+
+ for (int i = 0; i<currentDevices.length; i++) {
+ if (currentDevices[i] > -1)
+ count[currentDevices[i]]--;
+ }
+
return returnMessage;
}
- perfsonar: r3221 - in trunk/geant2_java-sshtelnet-mp: conf/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters samples src/main/java/org/perfsonar/service/measurementPoint/lookingGlassType/engine/adapters, svnlog, 01/14/2008
Archive powered by MHonArc 2.6.16.