-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/todo-adapter #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rossdanderson
wants to merge
8
commits into
develop
Choose a base branch
from
feature/improvements
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
43f02a6
Separate Container/Row/Type2 publishers
rossdanderson ff9c7fd
Remove redundant call
rossdanderson 1c89ce7
Feature/todo list adapter (#6)
rossdanderson 85ff877
Merge branch 'develop' of github.com:caplin/project-templates into fe…
a2dd8c4
fix config for pricing template
12b2ac8
Incorporate improvements from @rossdanderson
2cb8af0
use nexus url and credentials from gradle.properties file
85cede7
Merge branch 'develop' into feature/improvements
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,57 @@ | ||
| include-file ${ccd}/../../blade_config/bootstrap.conf | ||
|
|
||
| add-peer | ||
| label ${ADAPTER_NAME}${THIS_LEG} | ||
| remote-name ${ADAPTER_NAME}${THIS_LEG} | ||
| remote-type active | ||
| heartbeat-time 15 | ||
| heartbeat-slack-time 5 | ||
| end-peer | ||
|
|
||
| if "${FAILOVER}" == "ENABLED" | ||
| add-peer | ||
| label ${ADAPTER_NAME}${OTHER_LEG} | ||
| remote-type active | ||
| remote-name ${ADAPTER_NAME}${OTHER_LEG} | ||
| heartbeat-time 15 | ||
| heartbeat-slack-time 5 | ||
| end-peer | ||
| endif | ||
|
|
||
| add-data-service | ||
| service-name ${ADAPTER_NAME}ContainerSvc${THIS_LEG} | ||
| include-pattern ^/TEMPLATE/CONTAINER | ||
| include-pattern ^/TEMPLATE/TYPE2 | ||
|
|
||
| add-source-group | ||
| required | ||
| if "${FAILOVER}" == "ENABLED" | ||
| if "${LOAD_BALANCING}" == "ENABLED" | ||
| # | ||
| # Load balancing with 2 legs | ||
| # | ||
| add-priority | ||
| label ${ADAPTER_NAME}${THIS_LEG} | ||
| label ${ADAPTER_NAME}${OTHER_LEG} | ||
| end-priority | ||
| else | ||
| # | ||
| # Failover with 2 legs | ||
| # | ||
| add-priority | ||
| label ${ADAPTER_NAME}${THIS_LEG} | ||
| end-priority | ||
| add-priority | ||
| label ${ADAPTER_NAME}${OTHER_LEG} | ||
| end-priority | ||
| endif | ||
| else | ||
| # | ||
| # One leg only | ||
| # | ||
| add-priority | ||
| label ${ADAPTER_NAME}${THIS_LEG} | ||
| end-priority | ||
| endif | ||
| end-source-group | ||
| end-data-service |
This file contains hidden or 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 hidden or 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
64 changes: 26 additions & 38 deletions
64
...g-template/src/main/java/com/caplin/template/container/ContainerTemplateDataProvider.java
This file contains hidden or 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,68 +1,56 @@ | ||
| package com.caplin.template.container; | ||
|
|
||
| import java.util.logging.Level; | ||
|
|
||
| import com.caplin.datasource.DataSource; | ||
| import com.caplin.datasource.messaging.container.ContainerMessage; | ||
| import com.caplin.datasource.messaging.record.RecordType1Message; | ||
| import com.caplin.datasource.messaging.record.RecordType2Message; | ||
| import com.caplin.datasource.messaging.record.GenericMessage; | ||
| import com.caplin.datasource.namespace.PrefixNamespace; | ||
| import com.caplin.datasource.publisher.ActivePublisher; | ||
| import com.caplin.datasource.publisher.DataProvider; | ||
| import com.caplin.datasource.publisher.DiscardEvent; | ||
| import com.caplin.datasource.publisher.RequestEvent; | ||
|
|
||
| public class ContainerTemplateDataProvider implements DataProvider { | ||
| public class ContainerTemplateDataProvider { | ||
|
|
||
| private static final int NUM_CONSTITUENTS = 50; | ||
| private final DataSource dataSource; | ||
|
|
||
| private ActivePublisher publisher; | ||
| private ActivePublisher containerPublisher; | ||
| private ActivePublisher rowPublisher; | ||
|
|
||
| public ContainerTemplateDataProvider(DataSource dataSource) { | ||
| this.dataSource = dataSource; | ||
| } | ||
|
|
||
| public void initialise() { | ||
| publisher = dataSource.createActivePublisher(new PrefixNamespace("/TEMPLATE/CONTAINER"), this); | ||
| } | ||
| containerPublisher = dataSource.createActivePublisher(new PrefixNamespace("/TEMPLATE/CONTAINER/ALL"), new DataProvider() { | ||
| @Override | ||
| public void onRequest(RequestEvent requestEvent) { | ||
| ContainerMessage containerMessage = containerPublisher.getMessageFactory().createContainerMessage(requestEvent.getSubject()); | ||
| containerMessage.setDoNotAuthenticate(true); | ||
|
|
||
| @Override | ||
| public void onRequest(RequestEvent requestEvent) { | ||
| if (requestEvent.getSubject().equals("/TEMPLATE/CONTAINER/ALL")) { | ||
| ContainerMessage containerMessage = publisher.getMessageFactory().createContainerMessage(requestEvent.getSubject()); | ||
| containerMessage.setDoNotAuthenticate(true); | ||
|
|
||
| for (int i = 0; i < NUM_CONSTITUENTS; i++) { | ||
| containerMessage.addElement("/TEMPLATE/CONTAINERROW_" + i); | ||
| } | ||
|
|
||
| for (int i = 0; i < NUM_CONSTITUENTS; i++) { | ||
| containerMessage.addElement("/TEMPLATE/CONTAINERROW_" + i); | ||
| containerMessage.setImage(true); | ||
| containerPublisher.publishInitialMessage(containerMessage); | ||
| } | ||
|
|
||
| containerMessage.setImage(true); | ||
| publisher.publishInitialMessage(containerMessage); | ||
| } else if (requestEvent.getSubject().startsWith("/TEMPLATE/CONTAINERROW")) { | ||
| RecordType1Message message = publisher.getMessageFactory().createRecordType1Message(requestEvent.getSubject()); | ||
|
|
||
| message.setImage(true); | ||
| publisher.publishInitialMessage(message); | ||
| } else if (requestEvent.getSubject().equals("/TEMPLATE/TYPE2/ALL")) { | ||
| for (int i = 0; i < NUM_CONSTITUENTS; i++) { | ||
| @Override | ||
| public void onDiscard(DiscardEvent discardEvent) {} | ||
| }); | ||
|
|
||
| RecordType2Message type2Message = publisher.getMessageFactory().createRecordType2Message(requestEvent.getSubject(), "TYPE2_KEY", String.valueOf(i)); | ||
|
|
||
| if (i == 0) { | ||
| type2Message.setImage(true); | ||
| publisher.publishInitialMessage(type2Message); | ||
| } else { | ||
| publisher.publishToSubscribedPeers(type2Message); | ||
| } | ||
| rowPublisher = dataSource.createActivePublisher(new PrefixNamespace("/TEMPLATE/CONTAINER/CONTAINERROW"), new DataProvider() { | ||
| @Override | ||
| public void onRequest(RequestEvent requestEvent) { | ||
| GenericMessage updateMessage = rowPublisher.getMessageFactory().createGenericMessage(requestEvent.getSubject()); | ||
| updateMessage.setField("currentTime", String.valueOf(System.currentTimeMillis())); | ||
| rowPublisher.publishInitialMessage(updateMessage); | ||
| } | ||
| } else { | ||
| dataSource.getLogger().log(Level.INFO, "Unknown subject " + requestEvent.getSubject()); | ||
| } | ||
|
|
||
| @Override | ||
| public void onDiscard(DiscardEvent discardEvent) {} | ||
| }); | ||
| } | ||
|
|
||
| @Override | ||
| public void onDiscard(DiscardEvent discardEvent) {} | ||
| } |
47 changes: 47 additions & 0 deletions
47
pricing-template/src/main/java/com/caplin/template/type2/Type2DataProvider.java
This file contains hidden or 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,47 @@ | ||
| package com.caplin.template.type2; | ||
|
|
||
| import com.caplin.datasource.DataSource; | ||
| import com.caplin.datasource.messaging.record.RecordType2Message; | ||
| import com.caplin.datasource.namespace.PrefixNamespace; | ||
| import com.caplin.datasource.publisher.ActivePublisher; | ||
| import com.caplin.datasource.publisher.DataProvider; | ||
| import com.caplin.datasource.publisher.DiscardEvent; | ||
| import com.caplin.datasource.publisher.RequestEvent; | ||
|
|
||
| public class Type2DataProvider { | ||
|
|
||
| private static final int NUM_CONSTITUENTS = 50; | ||
|
|
||
| private final DataSource dataSource; | ||
|
|
||
| private ActivePublisher publisher; | ||
|
|
||
| public Type2DataProvider(DataSource dataSource) { | ||
| this.dataSource = dataSource; | ||
| } | ||
|
|
||
| public void initialise() { | ||
| publisher = dataSource.createActivePublisher(new PrefixNamespace("/TEMPLATE/TYPE2/ALL"), new DataProvider() { | ||
| @Override | ||
| public void onRequest(RequestEvent requestEvent) { | ||
| for (int i = 0; i < NUM_CONSTITUENTS; i++) { | ||
|
|
||
| RecordType2Message type2Message = publisher.getMessageFactory().createRecordType2Message( | ||
| requestEvent.getSubject(), "TYPE2_KEY", String.valueOf(i)); | ||
|
|
||
| if (i == 0) { | ||
| type2Message.setImage(true); | ||
| publisher.publishInitialMessage(type2Message); | ||
| } else { | ||
| publisher.publishToSubscribedPeers(type2Message); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onDiscard(DiscardEvent discardEvent) { | ||
| // Handle discard | ||
| } | ||
| }); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we already send Containers and Type2 records via transformer we should probably do the same for pricing