Skip to content

Commit

Permalink
Synchronized sessionCount number.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanKarab committed Jan 21, 2021
1 parent 225bf06 commit 3b1991f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import madgik.exareme.utils.eventProcessor.EventProcessor;

import java.rmi.RemoteException;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.util.Map;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
* @author herald
Expand All @@ -34,6 +36,7 @@ public class DynamicPlanManager implements PlanSessionManagerInterface {
private final HashMap<PlanSessionID, PlanSessionReportID> elasticTreeSessions = new HashMap<>();
private EventProcessor eventProcessor = null;
private long sessionCount = 0;
ReentrantLock sessionCountLock = new ReentrantLock();
private long containerSessionCount = 0;
/* ROOT sessions */
private Map<PlanSessionID, PlanEventScheduler> schedulerMap = null;
Expand Down Expand Up @@ -71,11 +74,13 @@ public void setExecutionEngine(ExecutionEngine executionEngine) {

@Override
public void createGlobalScheduler() throws RemoteException {
sessionCountLock.lock();
PlanSessionID sessionID = new PlanSessionID(sessionCount);
PlanSessionReportID reportID = new PlanSessionReportID(sessionCount);
reportID.reportManagerProxy = executionEngine.getPlanSessionReportManagerProxy(reportID);
sessionCount++;
sessionCountLock.unlock();

reportID.reportManagerProxy = executionEngine.getPlanSessionReportManagerProxy(reportID);
PlanEventScheduler eventScheduler =
new PlanEventScheduler(sessionID, reportID, eventProcessor, this, resourceManager,
registryProxy);
Expand All @@ -86,12 +91,13 @@ public void createGlobalScheduler() throws RemoteException {

@Override
public PlanSessionID createNewSession() throws RemoteException {
// TODO Is this thread safe?
sessionCountLock.lock();
PlanSessionID sessionID = new PlanSessionID(sessionCount);
PlanSessionReportID reportID = new PlanSessionReportID(sessionCount);
reportID.reportManagerProxy = executionEngine.getPlanSessionReportManagerProxy(reportID);
sessionCount++;
sessionCountLock.unlock();

reportID.reportManagerProxy = executionEngine.getPlanSessionReportManagerProxy(reportID);
PlanEventScheduler eventScheduler =
new PlanEventScheduler(sessionID, reportID, eventProcessor, this, resourceManager,
registryProxy);
Expand Down

0 comments on commit 3b1991f

Please sign in to comment.