Skip to content

Commit

Permalink
Use Google Java Format (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
slominskir authored Jul 8, 2024
1 parent bd26751 commit d28056c
Show file tree
Hide file tree
Showing 16 changed files with 2,338 additions and 2,040 deletions.
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'application'
id 'distribution'
id 'com.github.jk1.dependency-license-report' version '1.16'
id "com.diffplug.spotless" version "6.25.0"
}

group 'org.jlab'
Expand Down Expand Up @@ -90,3 +91,9 @@ startScripts {
unixScriptFile.text = unixScriptFile.text.replace('$APP_HOME/lib/config', '$APP_HOME/config')
}
}

spotless {
java {
googleJavaFormat()
}
}
651 changes: 352 additions & 299 deletions src/main/java/org/jlab/jaws/ActivationRule.java

Large diffs are not rendered by default.

112 changes: 64 additions & 48 deletions src/main/java/org/jlab/jaws/EffectiveProcessor.java
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);
}
}
Loading

0 comments on commit d28056c

Please sign in to comment.