-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd26751
commit d28056c
Showing
16 changed files
with
2,338 additions
and
2,040 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,76 @@ | ||
package org.jlab.jaws; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.concurrent.*; | ||
import org.jlab.jaws.clients.*; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.concurrent.*; | ||
public class EffectiveProcessor { | ||
private static final Logger log = LoggerFactory.getLogger(EffectiveProcessor.class); | ||
private static final Set<ProcessingRule> rules = new HashSet<>(); | ||
|
||
/** | ||
* Entrypoint of the application. | ||
* | ||
* @param args The command line arguments | ||
*/ | ||
public static void main(String[] args) { | ||
|
||
public class EffectiveProcessor { | ||
private static final Logger log = LoggerFactory.getLogger(EffectiveProcessor.class); | ||
private static final Set<ProcessingRule> rules = new HashSet<>(); | ||
|
||
/** | ||
* Entrypoint of the application. | ||
* | ||
* @param args The command line arguments | ||
*/ | ||
public static void main(String[] args) { | ||
|
||
// async | ||
rules.add(new ShelveExpirationRule(OverrideProducer.TOPIC, OverrideProducer.TOPIC)); | ||
|
||
// pipelined | ||
rules.add(new RegistrationRule(ClassProducer.TOPIC, InstanceProducer.TOPIC, EffectiveRegistrationProducer.TOPIC, "intermediate-registration")); | ||
rules.add(new ActivationRule("intermediate-registration", ActivationProducer.TOPIC, OverrideProducer.TOPIC, "intermediate-activation")); | ||
rules.add(new LatchRule("intermediate-activation", "intermediate-latch", OverrideProducer.TOPIC)); | ||
rules.add(new OneShotRule("intermediate-latch", "intermediate-oneshot", OverrideProducer.TOPIC)); | ||
rules.add(new EffectiveStateRule("intermediate-oneshot", EffectiveNotificationProducer.TOPIC, EffectiveAlarmProducer.TOPIC)); | ||
|
||
final CountDownLatch latch = new CountDownLatch(1); | ||
|
||
// attach shutdown handler to catch control-c | ||
Runtime.getRuntime().addShutdownHook(new Thread("streams-shutdown-hook") { | ||
@Override | ||
public void run() { | ||
for(ProcessingRule rule: rules) { | ||
try { | ||
rule.close(); | ||
} catch(Exception e) { | ||
log.warn("Unable to close rule", e); | ||
} | ||
// async | ||
rules.add(new ShelveExpirationRule(OverrideProducer.TOPIC, OverrideProducer.TOPIC)); | ||
|
||
// pipelined | ||
rules.add( | ||
new RegistrationRule( | ||
ClassProducer.TOPIC, | ||
InstanceProducer.TOPIC, | ||
EffectiveRegistrationProducer.TOPIC, | ||
"intermediate-registration")); | ||
rules.add( | ||
new ActivationRule( | ||
"intermediate-registration", | ||
ActivationProducer.TOPIC, | ||
OverrideProducer.TOPIC, | ||
"intermediate-activation")); | ||
rules.add( | ||
new LatchRule("intermediate-activation", "intermediate-latch", OverrideProducer.TOPIC)); | ||
rules.add( | ||
new OneShotRule("intermediate-latch", "intermediate-oneshot", OverrideProducer.TOPIC)); | ||
rules.add( | ||
new EffectiveStateRule( | ||
"intermediate-oneshot", | ||
EffectiveNotificationProducer.TOPIC, | ||
EffectiveAlarmProducer.TOPIC)); | ||
|
||
final CountDownLatch latch = new CountDownLatch(1); | ||
|
||
// attach shutdown handler to catch control-c | ||
Runtime.getRuntime() | ||
.addShutdownHook( | ||
new Thread("streams-shutdown-hook") { | ||
@Override | ||
public void run() { | ||
for (ProcessingRule rule : rules) { | ||
try { | ||
rule.close(); | ||
} catch (Exception e) { | ||
log.warn("Unable to close rule", e); | ||
} | ||
} | ||
latch.countDown(); | ||
} | ||
}); | ||
|
||
try { | ||
for(ProcessingRule rule: rules) { | ||
rule.start(); | ||
} | ||
latch.await(); | ||
} catch (final Throwable e) { | ||
System.exit(1); | ||
} | ||
System.exit(0); | ||
} | ||
}); | ||
|
||
try { | ||
for (ProcessingRule rule : rules) { | ||
rule.start(); | ||
} | ||
latch.await(); | ||
} catch (final Throwable e) { | ||
System.exit(1); | ||
} | ||
System.exit(0); | ||
} | ||
} |
Oops, something went wrong.