This commit is contained in:
parent
751da613a5
commit
537f8a3ff6
6 changed files with 64 additions and 6 deletions
|
|
@ -5,10 +5,14 @@ import org.slf4j.LoggerFactory;
|
|||
import ru.clearing.classes.statics.data.misc.Session;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.platform.enumeration.Section;
|
||||
import ru.spcex.platform.enumeration.SessionStatus;
|
||||
import ru.spcex.platform.enumeration.SessionType;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public abstract class AbstractSession {
|
||||
|
|
@ -26,12 +30,12 @@ public abstract class AbstractSession {
|
|||
this.messageResolver = messageResolver;
|
||||
}
|
||||
|
||||
protected <T, R> StageResult<R> runStage(TaskType type, ISessionStage stage) {
|
||||
protected <T, R> StageResult<R> runStage(TaskType type, ISessionStage stage) {
|
||||
return runStage(type, null, stage);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T, R> StageResult<R> runStage(TaskType type, T payload, ISessionStage stage) {
|
||||
protected <T, R> StageResult<R> runStage(TaskType type, T payload, ISessionStage stage) {
|
||||
continueRunning(type);
|
||||
log.info("session.id={} step {} started", currSession.getId(), currStage.get());
|
||||
Task<T> t = new Task<>(type, payload);
|
||||
|
|
@ -48,6 +52,7 @@ public abstract class AbstractSession {
|
|||
}
|
||||
|
||||
protected abstract void runSession(BaseRequest<?> req);
|
||||
|
||||
protected void endSession() {
|
||||
synchronized (this.currStage) {
|
||||
this.currStage.set(null);
|
||||
|
|
@ -73,4 +78,16 @@ public abstract class AbstractSession {
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean checkIsActive() {
|
||||
Session activeSession = sessionImdg.getSingleObjectByFieldValues(Map.of(
|
||||
"sectionType", sectionType().getKey(),
|
||||
"section", section().getKey(),
|
||||
"sessionStatus", SessionStatus.ACTV.getKey())
|
||||
);
|
||||
return activeSession != null;
|
||||
}
|
||||
|
||||
protected abstract Section section();
|
||||
|
||||
protected abstract SessionType sectionType();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,4 +163,14 @@ public class PrimaryAuctionB0Session extends AbstractSession implements Initiali
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Section section() {
|
||||
return Section.FOND;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SessionType sectionType() {
|
||||
return SessionType.IPO0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,4 +201,14 @@ public class PrimaryAuctionBnSession extends AbstractSession implements Initiali
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Section section() {
|
||||
return Section.FOND;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SessionType sectionType() {
|
||||
return SessionType.IPOB;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,4 +163,14 @@ public class PrimaryAuctionT0Session extends AbstractSession implements Initiali
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Section section() {
|
||||
return Section.FOND;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SessionType sectionType() {
|
||||
return SessionType.IPOT;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,4 +201,14 @@ public class SecondaryAuctionT0Session extends AbstractSession implements Initia
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Section section() {
|
||||
return Section.FOND;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SessionType sectionType() {
|
||||
return SessionType.TRDT;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class SessionManager {
|
|||
}
|
||||
|
||||
public void defineAndStartSession(LauncherCommandRequest commandRequest) {
|
||||
Long sessionId = commandRequest.getSessionId();
|
||||
// Long sessionId = commandRequest.getSessionId();
|
||||
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, commandRequest.getSessionType());
|
||||
Section section = IEnumKey.getEnumByKey(Section.class, commandRequest.getSection());
|
||||
if (sessionType == null || section == null) {
|
||||
|
|
@ -35,12 +35,13 @@ public class SessionManager {
|
|||
BaseRequest<?> baseRequest = new BaseRequest<>();
|
||||
AbstractSession session = null;
|
||||
switch (sessionType){
|
||||
case IPOB : session = primaryAuctionBnSession;
|
||||
case IPOT : session = primaryAuctionT0Session;
|
||||
case IPO0 : session = primaryAuctionBnSession;
|
||||
case IPOB -> session = primaryAuctionBnSession;
|
||||
case IPOT -> session = primaryAuctionT0Session;
|
||||
case IPO0 -> session = primaryAuctionB0Session;
|
||||
}
|
||||
|
||||
if (session != null) {
|
||||
//checkActive
|
||||
session.runSession(baseRequest);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue