use of alma.ADMINTEST1.statusBlockEvent1 in project ACS by ACS-Community.
the class SimpleSupplierConsumerClient method startReceiving.
public void startReceiving() throws Exception {
statusBlockEvent1 event1 = new statusBlockEvent1();
event1.counter1 = 0;
event1.counter2 = 0;
event1.counter3 = 0;
event1.flipFlop = true;
event1.myString = "myValue";
event1.onOff = OnOffStates.ON;
event1.period = 0.2f;
statusBlockEvent2 event2 = new statusBlockEvent2();
event2.counter1 = 0;
event2.counter2 = 0;
event2.counter3 = 0;
event2.flipFlop = true;
event2.myString = "myValue";
event2.onOff = alma.ADMINTEST2.OnOffStates.ON;
event2.period = 0.2f;
EventDescription ed = new EventDescription();
ed.count = 0;
ed.name = "description";
ed.timestamp = new Date().getTime();
for (int i = 0; i != m_times; i++) {
try {
// publish events of 2 different types
for (int j = 0; j != m_nEvents; j++) {
m_publisher.publishEvent(event1);
m_logger.info("Published event 1");
m_publisher.publishEvent(event2);
m_logger.info("Published event 2");
m_publisher.publishEvent(ed);
m_logger.info("Published event ed");
}
} catch (Exception e) {
m_logger.info("It was impossible to publish the event because an exception was thrown");
}
// Sleep and get events
try {
Thread.sleep(m_interval * 1000);
} catch (InterruptedException e) {
}
/*try {
m_subscriber.startReceivingEvents();
} catch(AcsJIllegalStateEventEx e) {
m_logger.info("AcsJIllegalStateEventEx thrown, perfect :D");
}*/
}
}
use of alma.ADMINTEST1.statusBlockEvent1 in project ACS by ACS-Community.
the class NCSubscriberTest method publish.
/*===================================*/
/* Support methods */
/*===================================*/
private void publish(int nEvents, EventType type) {
IDLEntity event = null;
if (type.equals(EventType.statusBlock1)) {
event = new statusBlockEvent1();
((statusBlockEvent1) event).counter1 = 0;
((statusBlockEvent1) event).counter2 = 0;
((statusBlockEvent1) event).flipFlop = true;
((statusBlockEvent1) event).onOff = alma.ADMINTEST1.OnOffStates.ON;
} else if (type.equals(EventType.statusBlock2)) {
event = new statusBlockEvent2();
((statusBlockEvent2) event).counter1 = 0;
((statusBlockEvent2) event).counter2 = 0;
((statusBlockEvent2) event).flipFlop = true;
((statusBlockEvent2) event).onOff = alma.ADMINTEST2.OnOffStates.ON;
}
try {
for (int i = 0; i != nEvents; i++) m_publisher.publishEvent(event);
} catch (AcsJException e) {
e.printStackTrace();
}
}
use of alma.ADMINTEST1.statusBlockEvent1 in project ACS by ACS-Community.
the class NCPublisherTest method testPublisherSendingEvents.
/**
* This test creates one Publisher to a channel and send events.
*/
public void testPublisherSendingEvents() throws Exception {
// Creating a new Publisher
int numEvents = 1000;
publisher = new NCPublisher<statusBlockEvent1>("testingChannel", services, Helper.getNamingServiceInitial(getContainerServices()));
assertTrue(publisher != null);
// Sending numEvents;
while (publisher.count.get() < numEvents) {
// Constructing the event
OnOffStates onOff = OnOffStates.ON;
statusBlockEvent1 event = null;
event = new statusBlockEvent1(onOff, "testingEvent", 0, (int) publisher.count.get(), numEvents, false, 100);
// Publishing the event
publisher.publishEvent(event);
// simulates the period
Thread.sleep((int) event.period);
}
}
use of alma.ADMINTEST1.statusBlockEvent1 in project ACS by ACS-Community.
the class ContinuousNcPublisher method run.
private void run(String channelName, int eventsPerBurst, int delayBurstsMillis, boolean logAfterBurst) throws AcsJException {
m_logger.info("Will continuously publish 'statusBlockEvent1' dummy events on NC '" + channelName + "', with bursts of " + eventsPerBurst + " events and delays of " + delayBurstsMillis + " ms between bursts.");
NCPublisher<statusBlockEvent1> publisher = null;
// publisher.enableEventQueue(queueSize, handler);
statusBlockEvent1 event = new statusBlockEvent1(OnOffStates.ON, "testingEvent", 0, 0, 0, false, 0.0f);
try {
publisher = new NCPublisher<statusBlockEvent1>(channelName, getContainerServices(), Helper.getNamingServiceInitial(getContainerServices()));
while (!Thread.currentThread().isInterrupted()) {
for (int i = 0; i < eventsPerBurst; i++) {
// m_logger.info("About to publish event");
publisher.publishEvent(event);
event.counter2++;
}
if (logAfterBurst) {
m_logger.info("Done with event burst " + event.counter1 + ".");
}
event.counter1++;
event.counter2 = 0;
try {
Thread.sleep(delayBurstsMillis);
} catch (InterruptedException ex) {
// while loop checks...
}
}
} finally {
if (publisher != null) {
publisher.disconnect();
}
m_logger.info("Done.");
}
}
use of alma.ADMINTEST1.statusBlockEvent1 in project ACS by ACS-Community.
the class SimpleSupplierReconnClient method startReceiving.
public void startReceiving() throws Exception {
statusBlockEvent1 event1 = new statusBlockEvent1();
event1.counter1 = 0;
event1.counter2 = 0;
event1.counter3 = 0;
event1.flipFlop = true;
event1.myString = "myValue";
event1.onOff = OnOffStates.ON;
event1.period = 0.2f;
m_publisher.increaseEventBufferSize(200);
int bufferSize = m_publisher.getEventBufferSize();
if (bufferSize < 200) {
m_logger.info("Wrong buffer size. Should be equal or greater than 200 but was " + String.valueOf(bufferSize));
}
m_publisher.setEventProcessingHandler(m_cbObj);
m_logger.info("NS action: " + m_nsAction);
if (m_autoreconnect) {
m_logger.info("Autoreconnection: ON");
} else {
m_logger.info("Autoreconnection: OFF");
}
m_logger.info("Start publishing " + String.valueOf(m_nEvents) + " events");
// publish events
for (int j = 0; j != m_nEvents; j++) {
try {
m_publisher.publishEvent(event1);
// Sleep
try {
Thread.sleep(m_interval * 100);
} catch (InterruptedException e) {
}
} catch (Throwable e) {
m_cbObj.exceptionThrown(e);
}
m_logger.info("Published events at iteration " + String.valueOf(j));
}
String transitions = "";
Iterator<Integer> it = m_cbObj.m_transitions.iterator();
while (it.hasNext()) {
transitions += String.valueOf(it.next()) + ",";
}
m_logger.info("=== Number of events sent: " + String.valueOf(m_cbObj.m_nEventsSent));
m_logger.info("=== Number of events queued: " + String.valueOf(m_cbObj.m_nEventsStored));
m_logger.info("=== Number of events dropped: " + String.valueOf(m_cbObj.m_nEventsDropped));
m_logger.info("=== Number of exceptions: " + String.valueOf(m_cbObj.m_nExceptions));
m_logger.info("=== Exceptions found: " + m_cbObj.exceptionsFound());
m_logger.info("=== Transitions: " + transitions);
if (m_autoreconnect) {
if (m_nsAction.equals(NS_RESTARTED)) {
if (m_cbObj.m_transitions.size() != 2 && m_cbObj.m_transitions.size() != 0) {
m_logger.info("=== Wrong number of transitions: " + String.valueOf(m_cbObj.m_transitions.size()) + ". We expected 0 or 2");
}
} else if (m_nsAction.equals(NS_STOPPED)) {
if (m_cbObj.m_transitions.size() != 1) {
m_logger.info("=== Wrong number of transitions: " + String.valueOf(m_cbObj.m_transitions.size()) + ". We expected 1");
}
} else {
m_logger.info("=== Wrong Notify Service action: " + m_nsAction);
}
} else {
if (m_nsAction.equals(NS_RESTARTED)) {
if (m_cbObj.m_transitions.size() != 1) {
m_logger.info("=== Wrong number of transitions: " + String.valueOf(m_cbObj.m_transitions.size()) + ". We expected 1");
}
} else if (m_nsAction.equals(NS_STOPPED)) {
if (m_cbObj.m_transitions.size() != 1) {
m_logger.info("=== Wrong number of transitions: " + String.valueOf(m_cbObj.m_transitions.size()) + ". We expected 1");
}
} else {
m_logger.info("=== Wrong Notify Service action: " + m_nsAction);
}
}
}
Aggregations