Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r2550 - in branches/new-structure/trunk/surfnet_java-flowsa-ma: . ant src/org/perfsonar/service/mesurementArchive/flowsa src/org/perfsonar/service/mesurementArchive/flowsa/nfdump src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/outputreaders

Subject: perfsonar development work

List archive

perfsonar: r2550 - in branches/new-structure/trunk/surfnet_java-flowsa-ma: . ant src/org/perfsonar/service/mesurementArchive/flowsa src/org/perfsonar/service/mesurementArchive/flowsa/nfdump src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/outputreaders


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r2550 - in branches/new-structure/trunk/surfnet_java-flowsa-ma: . ant src/org/perfsonar/service/mesurementArchive/flowsa src/org/perfsonar/service/mesurementArchive/flowsa/nfdump src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/outputreaders
  • Date: Wed, 18 Jul 2007 09:45:36 -0400

Author: michael.bischoff
Date: 2007-07-18 09:45:36 -0400 (Wed, 18 Jul 2007)
New Revision: 2550

Added:
branches/new-structure/trunk/surfnet_java-flowsa-ma/ant/const.properties
branches/new-structure/trunk/surfnet_java-flowsa-ma/conf/

branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/ActionType.java

branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/FlowStatisticsResponse.java

branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/RawFlowsResponse.java

branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/TopFlowsResponse.java

branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/RawFlowsQuery.java
Removed:

branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/FlowQuery.java
Modified:
branches/new-structure/trunk/surfnet_java-flowsa-ma/

branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/FlowsaMAServiceEngine.java

branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/NfdumpControll.java

branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/NfdumpOutputReader.java

branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/outputreaders/Nfdump152OutputReaderImpl.java
Log:



Property changes on: branches/new-structure/trunk/surfnet_java-flowsa-ma
___________________________________________________________________
Name: svn:ignore
+ .settings


Added:
branches/new-structure/trunk/surfnet_java-flowsa-ma/ant/const.properties

Added:
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/ActionType.java

Added:
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/FlowStatisticsResponse.java

Modified:
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/FlowsaMAServiceEngine.java
===================================================================
---
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/FlowsaMAServiceEngine.java
2007-07-17 15:17:22 UTC (rev 2549)
+++
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/FlowsaMAServiceEngine.java
2007-07-18 13:45:36 UTC (rev 2550)
@@ -13,49 +13,27 @@
import org.perfsonar.base.exceptions.PerfSONARException;
import org.perfsonar.service.base.engine.ServiceEngine;
import org.perfsonar.service.mesurementArchive.flowsa.nfdump.Flow;
-import org.perfsonar.service.mesurementArchive.flowsa.nfdump.FlowQuery;
import org.perfsonar.service.mesurementArchive.flowsa.nfdump.NfdumpControll;
+import org.perfsonar.service.mesurementArchive.flowsa.nfdump.RawFlowsQuery;
import org.perfsonar.service.mesurementArchive.flowsa.nfdump.Statistics;
import org.perfsonar.service.mesurementArchive.flowsa.nfdump.StatisticsQuery;
import org.perfsonar.service.mesurementArchive.flowsa.nfdump.TopData;
import org.perfsonar.service.mesurementArchive.flowsa.nfdump.TopQuery;
+import
org.perfsonar.service.mesurementArchive.flowsa.nfdump.filters.SimpleFilter;

+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+
/**
- * Flow Selection and Aggregation Mesurement Archive Service Engine
+ * Flow Selection and Aggregation Measurement Archive Service Engine
* implementation.
*
* (shortend to FlowSAMAServiceEngine for sanity reasons.)
*
- * @see org.perfsonar.service.commons.engine.ServiceEngine
+ * @see ServiceEngine
* @author Michael Bischoff
*/
public class FlowsaMAServiceEngine implements ServiceEngine {

- public enum ActionType {
- RAW_FLOW_REQUEST("RawFlowRequest"),
- STATISTICS_FLOW_REQUEST("StatisticsFlowRequest"),
- TOP_FLOW_REQUEST("TopFlowRequest");
-
- /**
- * Looks throught all ActionTypes(ActionType.values()) and looks
- * for an type belonging to this name.
- * @param name
- * @return the enum representing this value or null if not found
- */
- public static ActionType get(String name) {
- for(ActionType type : ActionType.values()) {
- if(type.name.equals(name)) return type;
- }
- return null;
- }
-
- private final String name;
-
- ActionType(String name) {
- this.name = name;
- }
- }
-
private final static String SERVICE_TYPE =
"service.MeasurementArchive.flowType";

private final LoggerComponent logger;
@@ -107,13 +85,29 @@
}

/**
- * takes the action and dispaches it to the appropriate handleXXX()
method
- * @see
org.perfsonar.service.commons.engine.ServiceEngine#takeAction(java.lang.String,
org.ggf.ns.nmwg.base.v2_0.Message)
+ * handles response, it calls processAction and converts exceptions to
perfsonar exceptions when raised.
+ * @param actionType associated with this message
+ * @param request send by the client.
+ * @return message to send back to the client.
+ * @throws PerfSONARException if this actionType is not implemented or
unknown.
+ * @see ServiceEngine#takeAction(java.lang.String,
org.ggf.ns.nmwg.base.v2_0.Message)
*/
public Message takeAction(final String actionType, Message request)
throws PerfSONARException {
- logger.debug("FlowSAMAServiceEngine.takeAction: Received a request
of type - " + actionType);
- ActionType type = ActionType.get(actionType);
+ logger.debug("FlowsaMAServiceEngine.takeAction: Received a request
of type - " + actionType);

+ try {
+ return processAction(actionType, request);
+ } catch (InterruptedException e) {
+ throw new
PerfSONARException("error.ma.fetching.interrupted","Fetching was
interrupted",e);
+ } catch (ExecutionException e) {
+ throw new PerfSONARException("error.ma.fetching","Exception
while fetching data",e);
+ } catch (TimeoutException e) {
+ throw new
PerfSONARException("error.ma.fetching.timeout","Fetching took too long");
+ }
+ }
+
+ private Message processAction(final String actionType, Message request)
throws PerfSONARException, InterruptedException, ExecutionException,
TimeoutException {
+ ActionType type = ActionType.get(actionType);
switch (type) {
case RAW_FLOW_REQUEST:
return handleRawFlowRequest(request);
@@ -133,95 +127,49 @@
"error.common.action_not_supported",
"Request type " + actionType + " not understood."
);
- }
+ }
}

- protected Message handleRawFlowRequest(Message request) throws
PerfSONARException {
- FlowQuery query = new FlowQuery();
- //TODO fill query from request
- List<Flow> result = null;
- try {
- result = nfdump.execute(query);
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (ExecutionException e) {
- throw new PerfSONARException("error.ma.fetching","Exception
while processing your request",e);
- } catch (TimeoutException e) {
- //TODO errorcode
- throw new PerfSONARException("","Request took too long to
process");
- }
-
- return createRawFlowResponse(result);
+ protected RawFlowsResponse handleRawFlowRequest(Message request) throws
InterruptedException, ExecutionException, TimeoutException {
+ RawFlowsQuery query = createFlowQueryFrom(request);
+ List<Flow> result = nfdump.execute(query);
+ RawFlowsResponse response = new RawFlowsResponse(result);
+ return response;
}

- protected Message handleStatisticsFlowRequest(Message request) throws
PerfSONARException {
+ protected Message handleStatisticsFlowRequest(Message request) throws
InterruptedException, ExecutionException, TimeoutException {
StatisticsQuery query = createStatisticsQueryFrom(request);
- Statistics statistics = null;
- try {
- statistics = nfdump.execute(query);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ExecutionException e) {
- throw new
PerfSONARException("error.ma.flow_sa.exception","Exception while processing
your request",e);
- } catch (TimeoutException e) {
- // TODO errorcode
- throw new PerfSONARException("error.ma.flow_sa.timeout","Request
took too long to process");
- }
- return createStatisticsResponse(statistics);
+ Statistics statistics = nfdump.execute(query);
+ return new FlowStatisticsResponse(statistics);
}

- protected FlowQuery createFlowQueryFrom(Message request) {
- // TODO create query
- return null;
+ protected Message handleTopFlowRequest(Message request) throws
InterruptedException, ExecutionException, TimeoutException {
+ TopQuery query = createTopQueryFrom(request);
+ TopData result = nfdump.execute(query);
+ return new TopFlowsResponse(result);
}
+
+ protected RawFlowsQuery createFlowQueryFrom(Message request) {
+ RawFlowsQuery query = new RawFlowsQuery();
+ query.setFilter(new SimpleFilter(""));
+ throw new NotImplementedException();
+ }
protected StatisticsQuery createStatisticsQueryFrom(Message request) {
// TODO create query
- return null;
+ throw new NotImplementedException();
}
protected TopQuery createTopQueryFrom(Message request) {
// TODO create query
- return null;
+ throw new NotImplementedException();
}

- protected Message handleTopFlowRequest(Message request) throws
PerfSONARException {
- TopQuery query = new TopQuery();
- List<TopData> result = null;
- try {
- result = nfdump.execute(query);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ExecutionException e) {
- // TODO errorcode
- throw new PerfSONARException("","Exception while processign your
request",e);
- } catch (TimeoutException e) {
- // TODO Auto-generated catch block
- throw new PerfSONARException("","Request took too long to
process");
- }
- return createTopFlowResponse(result);
- }
-
- protected Message createRawFlowResponse(List<Flow> result) {
- //TODO parse Flow in a message
- return null;
- }
-
- protected Message createStatisticsResponse(Statistics statistics) {
- // TODO parse Statistics in a Message
- return null;
- }
-
- protected Message createTopFlowResponse(List<TopData> topData) {
- // TODO parse TOPdata in a message
- return null;
- }
-
private File getExecutableFrom(ConfigurationComponent source) {
- String fileLocation = "";
+ String fileLocation = null;
try {
+ //TODO
fileLocation = source.getProperty("");
} catch (PerfSONARException e) {
+ logger.debug("No configuration found: using standard location
for nfDump");
return new File("/usr/local/bin/nfdump");
}
return new File(fileLocation);

Added:
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/RawFlowsResponse.java

Added:
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/TopFlowsResponse.java

Deleted:
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/FlowQuery.java

Modified:
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/NfdumpControll.java
===================================================================
---
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/NfdumpControll.java
2007-07-17 15:17:22 UTC (rev 2549)
+++
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/NfdumpControll.java
2007-07-18 13:45:36 UTC (rev 2550)
@@ -17,6 +17,8 @@

import
org.perfsonar.service.mesurementArchive.flowsa.nfdump.outputreaders.Nfdump152OutputReaderFactory;

+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+
/**
* Core of the nfdump wrapper.
*
@@ -98,7 +100,7 @@
* @throws ExecutionException wenn something went wrong executing the
query-task
* @throws TimeoutException wenn the query-task took too long
*/
- public List<Flow> execute(FlowQuery query) throws InterruptedException,
ExecutionException, TimeoutException {
+ public List<Flow> execute(RawFlowsQuery query) throws
InterruptedException, ExecutionException, TimeoutException {
List<String> commands = createCommandsFrom(query);

Callable<List<Flow>> task = new
NfdumpTask<List<Flow>>(commands,readerFactory) {
@@ -147,22 +149,29 @@
/**
* This method takes a TopQuery, executes it and returns the result.
* @param query to be executed
- * @return a non null List of TopData
- * @throws InterruptedException wenn waiting for timeout was interrupted
- * @throws ExecutionException wenn something went wrong executing the
query-task
- * @throws TimeoutException wenn the query-task took too long
+ * @return TopData
+ * @throws InterruptedException when waiting for timeout was interrupted
+ * @throws ExecutionException when something went wrong executing the
query-task
+ * @throws TimeoutException when the query-task took too long
*/
- public List<TopData> execute(TopQuery query) throws
InterruptedException, ExecutionException, TimeoutException {
+ public TopData execute(TopQuery query) throws InterruptedException,
ExecutionException, TimeoutException {
List<String> commands = createCommandsFrom(query);
- Callable<List<TopData>> task = new
NfdumpTask<List<TopData>>(commands,readerFactory) {
+ Callable<TopData> task = new
NfdumpTask<TopData>(commands,readerFactory) {
@Override
- public List<TopData> call(NfdumpOutputReader reader) throws
Exception {
- return null;//reader.readTopData();
+ public TopData call(NfdumpOutputReader reader) throws Exception {
+ throw new NotImplementedException();//reader.readTopData();
}
};
return submit(task);
}
-
+ /**
+ * @param <Type>
+ * @param task to be submitted
+ * @return result of type
+ * @throws InterruptedException if the Thread was interrupted
+ * @throws ExecutionException if it failed to process
+ * @throws TimeoutException if processing took too long
+ */
protected <Type> Type submit(final Callable<Type> task) throws
InterruptedException, ExecutionException, TimeoutException {
Future<Type> future = executorService.submit(task);
try {
@@ -210,9 +219,9 @@
* to be converted
* @return a List of commands(String) that can be passed onto a
* Processbuilder
- * @see FlowQuery
+ * @see RawFlowsQuery
*/
- protected List<String> createCommandsFrom(FlowQuery query) {
+ protected List<String> createCommandsFrom(RawFlowsQuery query) {
List<String> commands = createCommandsForRecordQuery();
// commands.add(TIME_FLAG);


Modified:
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/NfdumpOutputReader.java
===================================================================
---
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/NfdumpOutputReader.java
2007-07-17 15:17:22 UTC (rev 2549)
+++
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/NfdumpOutputReader.java
2007-07-18 13:45:36 UTC (rev 2550)
@@ -2,8 +2,6 @@

import java.io.IOException;

-
-
/**
* Interface for Nfdump output readers
*
@@ -13,4 +11,5 @@
public interface NfdumpOutputReader {
public Flow readRecord() throws IOException;
public Statistics readStatistics() throws IOException;
+ public TopData readTopData() throws IOException;
}

Copied:
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/RawFlowsQuery.java
(from rev 2535,
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/FlowQuery.java)

Modified:
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/outputreaders/Nfdump152OutputReaderImpl.java
===================================================================
---
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/outputreaders/Nfdump152OutputReaderImpl.java
2007-07-17 15:17:22 UTC (rev 2549)
+++
branches/new-structure/trunk/surfnet_java-flowsa-ma/src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/outputreaders/Nfdump152OutputReaderImpl.java
2007-07-18 13:45:36 UTC (rev 2550)
@@ -8,14 +8,15 @@
import org.perfsonar.service.mesurementArchive.flowsa.nfdump.Flow;
import
org.perfsonar.service.mesurementArchive.flowsa.nfdump.NfdumpOutputReader;
import org.perfsonar.service.mesurementArchive.flowsa.nfdump.Statistics;
+import org.perfsonar.service.mesurementArchive.flowsa.nfdump.TopData;


/**
- * implementation of an
{@link
NfdumpOutputReader} specficly for version 1.5.2
+ * implementation of an
{@link
NfdumpOutputReader} specificly for version 1.5.2
* of nfdump depending on how the -pipe format changes over versions this
class
- * could be reused fpr other versions
+ * could be reused for other versions
*
- * @author michael
+ * @author Michael Bischoff
* @see NfdumpOutputReader
*/
public class Nfdump152OutputReaderImpl implements NfdumpOutputReader {
@@ -49,13 +50,25 @@
return null;
}

- private Flow parseRecord(String line) {
+ public Statistics readStatistics() {
+// Statistics statistics = new Statistics();
+// statistics.
+ return null;
+ }
+
+ public TopData readTopData() throws IOException {
+ TopData data = new TopData();
+ return null;
+ }
+
+ private Flow parseRecord(String line) throws IOException {
String[] values = line.split("\\|", 25);
-
+
if (values.length != 24) {
// hell.raise()
+ throw new IOException("Cannot read nfdump output: Line did not
sadisfy the right format.");
}
-
+
Flow record = new Flow();
record.setAdressFamily(values[0]);
record.setTimeFirstSeen(values[1]);
@@ -65,8 +78,7 @@
record.setProtocol(values[5]);
record.setSourceAddress(values[6] + values[7] + values[8] +
values[9]);
record.setSourcePort(values[10]);
- record.setDestinationAdress(values[11] + values[12] + values[13]
- + values[14]);
+ record.setDestinationAdress(values[11] + values[12] + values[13] +
values[14]);
record.setDestinationPort(values[15]);
record.setSourceAsNumber(values[16]);
record.setDestinationAsNumber(values[17]);
@@ -76,13 +88,8 @@
record.setTypeOfService(values[21]);
record.setPackets(values[22]);
record.setBytes(values[23]);
-
+
return record;
}

- public Statistics readStatistics() {
- // TODO Auto-generated method stub
- return null;
- }
-
}



  • perfsonar: r2550 - in branches/new-structure/trunk/surfnet_java-flowsa-ma: . ant src/org/perfsonar/service/mesurementArchive/flowsa src/org/perfsonar/service/mesurementArchive/flowsa/nfdump src/org/perfsonar/service/mesurementArchive/flowsa/nfdump/outputreaders, svnlog, 07/18/2007

Archive powered by MHonArc 2.6.16.

Top of Page