-
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
d275aaf
commit 1c8162e
Showing
33 changed files
with
162 additions
and
97 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
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
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
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
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
File renamed without changes.
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
22 changes: 22 additions & 0 deletions
22
common-configs/src/main/java/com/file/monitoring/common/configs/Catalog.java
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.file.monitoring.common.configs; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public final class Catalog { | ||
private static final Map<String, Chain> catalog = new ConcurrentHashMap<>(); | ||
|
||
public void addChain(Chain chain) throws Exception { | ||
if (chain == null) { | ||
throw new Exception("Invalid Argument Exception"); | ||
} | ||
catalog.put(chain.getName(), chain); | ||
} | ||
|
||
public Chain getChain(String chainName) throws Exception { | ||
if (chainName == null) { | ||
throw new Exception("Invalid Argument Exception"); | ||
} | ||
return catalog.get(chainName); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
common-configs/src/main/java/com/file/monitoring/common/configs/Chain.java
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.file.monitoring.common.configs; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.HashMap; | ||
import java.util.LinkedList; | ||
|
||
public final class Chain { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(Chain.class); | ||
|
||
private LinkedList<Command> commands = new LinkedList<>(); | ||
private final String name; | ||
|
||
public Chain(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void addCommand(Command command) { | ||
this.commands.add(command); | ||
} | ||
|
||
public void execute(HashMap<String, Object> context) { | ||
for (Command command : this.commands) { | ||
boolean chainMustEnd; | ||
try { | ||
chainMustEnd = command.execute(context); | ||
} catch (Exception e) { | ||
chainMustEnd = Command.COMPLETE_PROCESSING; | ||
LOGGER.error("Stopping Chain Execution. ", e); | ||
} | ||
|
||
if (chainMustEnd){ | ||
break; | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
common-configs/src/main/java/com/file/monitoring/common/configs/Command.java
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.file.monitoring.common.configs; | ||
|
||
import java.util.HashMap; | ||
|
||
public interface Command { | ||
boolean CONTINUE_PROCESSING = false; | ||
boolean COMPLETE_PROCESSING = true; | ||
|
||
boolean execute(HashMap<String, Object> context) throws Exception; | ||
|
||
} |
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
4 changes: 2 additions & 2 deletions
4
...com/file/monitoring/common/configs/commands/processors/CommonFileMonitoringProcessor.java
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,9 +1,9 @@ | ||
package com.file.monitoring.common.configs.commands.processors; | ||
|
||
import org.apache.commons.chain.Context; | ||
import java.util.HashMap; | ||
|
||
public interface CommonFileMonitoringProcessor { | ||
|
||
void process(Context context) throws Exception; | ||
void process(HashMap<String, Object> context) throws Exception; | ||
|
||
} |
5 changes: 2 additions & 3 deletions
5
...om/file/monitoring/common/configs/commands/validators/CommonFileMonitoringValidators.java
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,11 +1,10 @@ | ||
package com.file.monitoring.common.configs.commands.validators; | ||
|
||
import org.apache.commons.chain.Context; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
public interface CommonFileMonitoringValidators { | ||
|
||
List<String> validate(Context context) throws Exception; | ||
List<String> validate(HashMap<String, Object> context) throws Exception; | ||
|
||
} |
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
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
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
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
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
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
Oops, something went wrong.