List of usage examples for org.apache.commons.net.ntp TimeStamp getCurrentTime
public static TimeStamp getCurrentTime()
From source file:it.cnr.isti.labse.glimpse.manager.GlimpseManager.java
public void setupConnection(TopicConnectionFactory connectionFact, InitialContext initConn) { try {/*from w w w .java 2 s .c o m*/ DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating connection object "); connection = connectionFact.createTopicConnection(); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating public session object "); publishSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating subscribe object"); subscribeSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Setting up destination topic "); connectionTopic = (Topic) initConn.lookup(serviceTopic); tPub = publishSession.createPublisher(connectionTopic); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Setting up reading topic "); tSub = subscribeSession.createSubscriber(connectionTopic, "DESTINATION = 'monitor'", true); tSub.setMessageListener(this); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating response dispatcher "); responder = new ResponseDispatcher(initConn, connectionFact, requestMap); DebugMessages.ok(); } catch (JMSException e) { e.printStackTrace(); } catch (NamingException e) { e.printStackTrace(); } }
From source file:it.cnr.isti.labse.glimpse.impl.ComplexEventProcessorImpl.java
public void init(TopicConnectionFactory connectionFact, InitialContext initConn) { try {// w w w . ja v a 2 s. com DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating connection object "); connection = connectionFact.createTopicConnection(); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating public session object "); publishSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating subscribe object "); subscribeSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Setting up reading topic "); connectionTopic = (Topic) initConn.lookup(topic); tSub = subscribeSession.createSubscriber(connectionTopic, null, true); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Setting up destination topic "); connectionTopic = publishSession.createTopic(this.topic); tPub = publishSession.createPublisher(connectionTopic); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Reading knowledge base "); kbase = readKnowledgeBase(); ksession = kbase.newStatefulKnowledgeSession(); ksession.setGlobal("EVENTS EntryPoint", eventStream); eventStream = ksession.getWorkingMemoryEntryPoint("DEFAULT"); cepRuleManager = new DroolsRulesManager(kbuilder, kbase, ksession); DebugMessages.ok(); } catch (JMSException e) { e.printStackTrace(); } catch (NamingException e) { e.printStackTrace(); } }
From source file:eu.learnpad.simulator.mon.utils.Manager.java
public static Properties createProbeSettingsPropertiesObject(String javaNamingFactoryInitial, String javaNamingProviderUrl, String javaNamingSecurityPrincipal, String javaNamingSecurityCredential, String connectionFactoryNames, String topicProbeTopic, boolean debug, String probeName, String probeChannel) {/* w ww .ja va2s. c o m*/ if (debug) DebugMessages.print(TimeStamp.getCurrentTime(), GlimpseAbstractProbe.class.getSimpleName(), "Creating Properties object "); Properties settings = new Properties(); settings.setProperty("java.naming.factory.initial", javaNamingFactoryInitial); settings.setProperty("java.naming.provider.url", javaNamingProviderUrl); settings.setProperty("java.naming.security.principal", javaNamingSecurityPrincipal); settings.setProperty("java.naming.security.credential", javaNamingSecurityCredential); settings.setProperty("connectionFactoryNames", connectionFactoryNames); settings.setProperty("topic.probeTopic", topicProbeTopic); settings.setProperty("probeName", probeName); settings.setProperty("probeChannel", probeChannel); if (debug) { DebugMessages.ok(); DebugMessages.line(); } return settings; }
From source file:eu.learnpad.simulator.mon.manager.GlimpseManager.java
public void setupConnection(TopicConnectionFactory connectionFact, InitialContext initConn) { try {//from ww w. ja v a 2s . c o m DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating connection object "); connection = connectionFact.createTopicConnection(); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating public session object "); publishSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating subscribe object"); subscribeSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Setting up destination topic "); connectionTopic = (Topic) initConn.lookup(serviceTopic); tPub = publishSession.createPublisher(connectionTopic); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Setting up reading topic "); tSub = subscribeSession.createSubscriber(connectionTopic, "DESTINATION = 'monitor'", true); tSub.setMessageListener(this); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating response dispatcher "); responder = new ResponseDispatcher(initConn, connectionFact, requestMap, learnerAssessmentManager); if (responder != null) DebugMessages.ok(); } catch (JMSException e) { e.printStackTrace(); } catch (NamingException e) { e.printStackTrace(); } }
From source file:eu.learnpad.simulator.mon.impl.ComplexEventProcessorImpl.java
public void init(TopicConnectionFactory connectionFact, InitialContext initConn) { try {/*from w w w .j av a2 s . c o m*/ DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating connection object "); connection = connectionFact.createTopicConnection(); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating public session object "); publishSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating subscribe object "); subscribeSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Setting up reading topic "); connectionTopic = (Topic) initConn.lookup(topic); tSub = subscribeSession.createSubscriber(connectionTopic, null, true); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Setting up destination topic "); connectionTopic = publishSession.createTopic(this.topic); tPub = publishSession.createPublisher(connectionTopic); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Reading knowledge base "); knowledgeBase = createKnowledgeBase(); ksession = knowledgeBase.newStatefulKnowledgeSession(); ksession.setGlobal("EVENTS EntryPoint", eventStream); eventStream = ksession.getWorkingMemoryEntryPoint("DEFAULT"); cepRuleManager = new DroolsRulesManager(knowledgeBuilder, knowledgeBase, ksession); DebugMessages.ok(); } catch (JMSException e) { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), e.getMessage()); } catch (NamingException e) { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), e.getMessage()); } }
From source file:eu.learnpad.simulator.mon.example.MyGlimpseProbe_BPMN_LearnPAd.java
private void generateAndSendExample_GlimpseBaseEvents_StringPayload(String data, int sendingInterval) throws UnknownHostException { DebugMessages.ok();//from w w w. ja v a 2 s .c o m DebugMessages.print(TimeStamp.getCurrentTime(), MyGlimpseProbe_BPMN_LearnPAd.class.getName(), "Creating GlimpseBaseEventBPMN message"); GlimpseBaseEventBPMN<String> message; DebugMessages.ok(); DebugMessages.line(); try { AbstractEvent theEvent = new SessionScoreUpdateEvent(); for (int i = 0; i < 1000; i++) { Vector<Learner> usersInvolved = new Vector<>(); usersInvolved.add(new Learner(1, 12, "testName1", "testSurname1")); usersInvolved.add(new Learner(2, 24, "testName2", "testSurname2")); message = new GlimpseBaseEventBPMN<String>(data, "aGenericProbe", System.currentTimeMillis(), "EventGeneratedFromActivitiEngineSimulated", false, "ExtraField", theEvent); this.sendEventMessage(message, false); DebugMessages.println(TimeStamp.getCurrentTime(), MyGlimpseProbe_BPMN_LearnPAd.class.getName(), "GlimpseBaseEventBPMN message sent: {\n" + "eventName: " + message.getEventName() + "\n" + "eventData: " + message.getEventData() + "\n" + "timestamp: " + message.getTimeStamp() + "\n" + "extraField: " + message.getExtraDataField() + "\n" + "sessionID_Field: " + message.event.simulationsessionid + "\n" + "usersInvolvedSize: " + message.event.involvedusers + "\n" + "eventType: " + message.event.type + "}"); DebugMessages.line(); Thread.sleep(sendingInterval); } } catch (JMSException e1) { e1.printStackTrace(); } catch (NamingException e1) { e1.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:it.cnr.isti.labsedc.glimpse.impl.ComplexEventProcessorImpl.java
public void init(TopicConnectionFactory connectionFact, InitialContext initConn) { try {//from ww w .j av a 2s. c om DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating connection object "); connection = connectionFact.createTopicConnection(); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating public session object "); publishSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating subscribe object "); subscribeSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Setting up reading topic "); connectionTopic = (Topic) initConn.lookup(topic); tSub = subscribeSession.createSubscriber(connectionTopic, null, true); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Setting up destination topic "); connectionTopic = publishSession.createTopic(this.topic); tPub = publishSession.createPublisher(connectionTopic); DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Reading knowledge base "); knowledgeBase = createKnowledgeBase(); ksession = knowledgeBase.newStatefulKnowledgeSession(); ksession.setGlobal("EVENTS EntryPoint", eventStream); eventStream = ksession.getWorkingMemoryEntryPoint("DEFAULT"); cepRuleManager = new DroolsRulesManager(knowledgeBuilder, knowledgeBase, ksession); DebugMessages.ok(); } catch (JMSException e) { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), e.getMessage()); } catch (NamingException e) { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), e.getMessage()); } }
From source file:eu.learnpad.simulator.mon.probe.GlimpseAbstractProbe.java
/** * This method setup a {@link TopicConnection} object. * /* ww w . ja va 2 s .co m*/ * @param initConn the InitialContext object generated using the method {@link #initConnection(Properties, boolean)}. * @param settings can be generated automatically using {@link Manager#createProbeSettingsPropertiesObject(String, String, String, String, String, String, boolean, String, String)} * @param probeChannel * @param settings * @param debug * @return a {@link TopicPublisher} object * @throws NamingException * @throws JMSException */ protected TopicPublisher createConnection(InitialContext initConn, String probeChannel, Properties settings, boolean debug) throws NamingException, JMSException { if (debug) DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating ConnectionFactory with settings "); TopicConnectionFactory connFact = (TopicConnectionFactory) initConn .lookup(settings.getProperty("connectionFactoryNames")); if (debug) { DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating TopicConnection "); } connection = connFact.createTopicConnection(); if (debug) { DebugMessages.ok(); DebugMessages.line(); } if (debug) { DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating Session "); } publishSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); if (debug) { DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Looking up for channel "); } connectionTopic = (Topic) initContext.lookup(probeChannel); if (debug) { DebugMessages.ok(); DebugMessages.print(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Creating Publisher "); } return tPub = publishSession.createPublisher(connectionTopic); }
From source file:it.cnr.isti.labse.glimpse.MainMonitoring.java
public static boolean init() { boolean successfullInit = false; try {/*w ww. j ava2 s .c o m*/ //the connection are initialized Properties environmentParameters = Manager.Read(ENVIRONMENTPARAMETERSFILE); initConn = new InitialContext(environmentParameters); DebugMessages.print(TimeStamp.getCurrentTime(), MainMonitoring.class.getSimpleName(), "Setting up TopicConnectionFactory"); connFact = (TopicConnectionFactory) initConn.lookup("TopicCF"); DebugMessages.ok(); DebugMessages.line(); successfullInit = true; } catch (NamingException e) { e.printStackTrace(); successfullInit = false; } catch (Exception e) { e.printStackTrace(); successfullInit = false; } return successfullInit; }
From source file:eu.learnpad.simulator.mon.MainMonitoring.java
public static boolean init() { boolean successfullInit = false; try {/*from w w w.j a v a2 s. com*/ //the connection are initialized environmentParameters = Manager.Read(ENVIRONMENTPARAMETERSFILE); initConn = new InitialContext(environmentParameters); DebugMessages.println(TimeStamp.getCurrentTime(), MainMonitoring.class.getSimpleName(), "Connection Parameters"); DebugMessages.line(); DebugMessages.println(TimeStamp.getCurrentTime(), MainMonitoring.class.getSimpleName(), "java.naming.factory.initial " + environmentParameters.getProperty("java.naming.factory.initial")); DebugMessages.println(TimeStamp.getCurrentTime(), MainMonitoring.class.getSimpleName(), "java.naming.provider.url " + environmentParameters.getProperty("java.naming.provider.url")); DebugMessages.println(TimeStamp.getCurrentTime(), MainMonitoring.class.getSimpleName(), "java.naming.security.principal " + environmentParameters.getProperty("java.naming.security.principal")); DebugMessages.println(TimeStamp.getCurrentTime(), MainMonitoring.class.getSimpleName(), "java.naming.security.credentials " + environmentParameters.getProperty("java.naming.security.credentials")); DebugMessages.println(TimeStamp.getCurrentTime(), MainMonitoring.class.getSimpleName(), "connectionFactoryNames " + environmentParameters.getProperty("connectionFactoryNames")); DebugMessages.println(TimeStamp.getCurrentTime(), MainMonitoring.class.getSimpleName(), "topic.serviceTopic " + environmentParameters.getProperty("topic.serviceTopic")); DebugMessages.println(TimeStamp.getCurrentTime(), MainMonitoring.class.getSimpleName(), "topic.probeTopic " + environmentParameters.getProperty("topic.probeTopic")); DebugMessages.line(); DebugMessages.print(TimeStamp.getCurrentTime(), MainMonitoring.class.getSimpleName(), "Setting up TopicConnectionFactory"); connFact = (TopicConnectionFactory) initConn.lookup("TopicCF"); DebugMessages.ok(); DebugMessages.line(); successfullInit = true; } catch (NamingException e) { e.printStackTrace(); successfullInit = false; } catch (Exception e) { e.printStackTrace(); successfullInit = false; } return successfullInit; }