Skip to content

Commit

Permalink
MATP-1102 Fixed some issues with strategy message display, removed ru…
Browse files Browse the repository at this point in the history
…ntime update event
  • Loading branch information
colinduplantis committed Mar 16, 2023
1 parent 93b2213 commit 33c7f91
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 214 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public DisplayStrategyInstance(String inName,
owner.setValue(inOwnerName);
strategyStatus.setValue(StrategyStatus.PREPARING);
uploadProgress.setValue(0.0);
started.setValue(new Period(0));
started.setValue(null);
uptime.setValue(new Period(0));
setupRuntimeListener();
}
/**
* Create a new DisplayStrategy instance.
Expand All @@ -55,31 +57,22 @@ public DisplayStrategyInstance(StrategyInstance inStrategyInstance)
strategyName.setValue(inStrategyInstance.getName());
owner.setValue(inStrategyInstance.getUser().getName());
strategyStatus.setValue(inStrategyInstance.getStatus());
switch(inStrategyInstance.getStatus()) {
case ERROR:
case LOADING:
case STOPPED:
started.setValue(new Period(0));
break;
case RUNNING:
updateRunningProperty(inStrategyInstance.getStarted());
break;
default:
break;
}
started.setValue(inStrategyInstance.getStarted());
setupRuntimeListener();
updateRunningProperty();
}
/**
*
*
*
* @param inRunningValue
*/
public void updateRunningProperty(Date inRunningValue)
public void updateRunningProperty()
{
if(inRunningValue == null) {
started.setValue(new Period(0));
if(started.get() == null || started.get().getTime() == 0) {
uptime.setValue(new Period(0));
} else {
started.setValue(new Period(DateTime.now().minus(inRunningValue.getTime()).getMillis()));
uptime.setValue(new Period(DateTime.now().minus(started.get().getTime()).getMillis()));
}
}
/**
Expand All @@ -92,13 +85,13 @@ public ReadOnlyStringProperty strategyNameProperty()
return strategyName;
}
/**
* Get the started value.
* Get the uptime value.
*
* @return an <code>ObjectProperty&lt;Period&gt;</code> value
*/
public ObjectProperty<Period> startedProperty()
public ObjectProperty<Period> uptimeProperty()
{
return started;
return uptime;
}
/**
* Get the owner value.
Expand All @@ -109,6 +102,15 @@ public ReadOnlyStringProperty ownerProperty()
{
return owner;
}
/**
* Get the started property.
*
* @return an <code>ObjectProperty&lt;Date&gt;</code> value
*/
public ObjectProperty<Date> startedProperty()
{
return started;
}
/**
* Get the strategyStatus value.
*
Expand All @@ -122,8 +124,13 @@ public DoubleProperty uploadProgressProperty()
{
return uploadProgress;
}
private void setupRuntimeListener()
{
strategyStatus.addListener((observableValue,oldValue,newValue) -> updateRunningProperty());
}
private final ObjectProperty<Date> started = new SimpleObjectProperty<>();
private final StringProperty strategyName = new SimpleStringProperty();
private final ObjectProperty<Period> started = new SimpleObjectProperty<>();
private final ObjectProperty<Period> uptime = new SimpleObjectProperty<>();
private final StringProperty owner = new SimpleStringProperty();
private final ObjectProperty<StrategyStatus> strategyStatus = new SimpleObjectProperty<>();
private final DoubleProperty uploadProgress = new SimpleDoubleProperty();
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions photon/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
*****************
* strategy view *
*****************
- don't need runtime update - can calculate locally until the status changes
- reverify strategy before starting
- how to identify the strategy instance for events emitted through the strategy client? maybe create a special kind of client that knows the strategy instance? otherwise, we run the risk of a strategy impersonating another strategy.
- cancel big uploads
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.marketcetera.admin.UserFactory;
import org.marketcetera.core.Preserve;
import org.marketcetera.rpc.base.BaseRpcUtil;
import org.marketcetera.strategy.events.SimpleStrategyRuntimeUpdateEvent;
import org.marketcetera.strategy.events.SimpleStrategyStartFailedEvent;
import org.marketcetera.strategy.events.SimpleStrategyStartedEvent;
import org.marketcetera.strategy.events.SimpleStrategyStatusChangedEvent;
Expand All @@ -17,7 +16,6 @@
import org.marketcetera.strategy.events.SimpleStrategyUploadFailedEvent;
import org.marketcetera.strategy.events.SimpleStrategyUploadSucceededEvent;
import org.marketcetera.strategy.events.StrategyEvent;
import org.marketcetera.strategy.events.StrategyRuntimeUpdateEvent;
import org.marketcetera.strategy.events.StrategyStartFailedEvent;
import org.marketcetera.strategy.events.StrategyStartedEvent;
import org.marketcetera.strategy.events.StrategyStatusChangedEvent;
Expand Down Expand Up @@ -201,7 +199,6 @@ public static void setStrategyEvent(StrategyEvent inStrategyEvent,
if(inStrategyEvent instanceof StrategyUploadFailedEvent) {
StrategyUploadFailedEvent failedEvent = (StrategyUploadFailedEvent)inStrategyEvent;
rpcEventBuilder.setMessage(failedEvent.getErrorMessage());
} else if(inStrategyEvent instanceof StrategyRuntimeUpdateEvent) {
} else if(inStrategyEvent instanceof StrategyUploadSucceededEvent) {
} else if(inStrategyEvent instanceof StrategyUnloadedEvent) {
} else if(inStrategyEvent instanceof StrategyStartedEvent) {
Expand Down Expand Up @@ -241,10 +238,6 @@ public static StrategyEvent getStrategyEvent(StrategyRpc.StrategyEventListenerRe
if(strategyInstanceOption.isPresent()) {
StrategyInstance strategyInstance = strategyInstanceOption.get();
switch(rpcEvent.getEventType()) {
case "SimpleStrategyRuntimeUpdateEvent":
SimpleStrategyRuntimeUpdateEvent updateEvent = new SimpleStrategyRuntimeUpdateEvent();
updateEvent.setStrategyInstance(strategyInstance);
return updateEvent;
case "SimpleStrategyStartedEvent":
SimpleStrategyStartedEvent startEvent = new SimpleStrategyStartedEvent();
startEvent.setStrategyInstance(strategyInstance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
type="org.marketcetera.strategy.StrategyStatus" pojoType="org.marketcetera.strategy.StrategyStatus" apiType="org.marketcetera.strategy.StrategyStatus"/>
</modelEventAttributes>
</modelEvent>
<modelEvent name="StrategyRuntimeUpdateEvent" description="Indicates that a strategy runtime has changed" pojoProject="strategy/strategy-core" apiProject="strategy/strategy-api" packageName="org.marketcetera.strategy.events" apiExtends="org.marketcetera.strategy.HasStrategyInstance,org.marketcetera.strategy.events.StrategyEvent">
<modelEvent name="StrategyMessageEvent" description="Indicates that a strategy message was added" pojoProject="strategy/strategy-core" apiProject="strategy/strategy-api" packageName="org.marketcetera.strategy.events" apiExtends="org.marketcetera.strategy.HasStrategyMessage">
<authors>
<author>&lt;a href="mailto:colin@marketcetera.com"&gt;Colin DuPlantis&lt;/a&gt;</author>
</authors>
<modelEventAttributes>
<modelEventAttribute name="strategyInstance" description="strategy instance for which the runtime is being updated" useGetters="true" useSetters="true" interfaceProvided="true"
type="org.marketcetera.strategy.StrategyInstance" pojoType="org.marketcetera.strategy.StrategyInstance" apiType="org.marketcetera.strategy.StrategyInstance"/>
<modelEventAttribute name="strategyMessage" description="strategy message that was created" useGetters="true" useSetters="true" interfaceProvided="true"
type="org.marketcetera.strategy.StrategyMessage" pojoType="org.marketcetera.strategy.StrategyMessage" apiType="org.marketcetera.strategy.StrategyMessage"/>
</modelEventAttributes>
</modelEvent>
</modelEvents>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.Collection;
import java.util.Date;
import java.util.Optional;

import org.apache.commons.lang.Validate;
Expand Down Expand Up @@ -143,6 +144,7 @@ public void emitMessage(Severity inSeverity,
strategyMessage.setSeverity(inSeverity);
strategyMessage.setMessage(inMessage);
strategyMessage.setStrategyInstance(getStrategyInstanceHolder().getStrategyInstance());
strategyMessage.setMessageTimestamp(new Date());
getStrategyService().createStrategyMessage(strategyMessage);
}
/* (non-Javadoc)
Expand Down
Loading

0 comments on commit 33c7f91

Please sign in to comment.