@Test public void testPollingEmptySession() { int currTime = 0; assertNull(singleDataItemStatSession.pollCloudlets(currTime)); }
public StepCloudlets pollCloudlets(final double currTime) { StepCloudlets result = null; boolean appCloudletFinished = currentAppServerCloudLet == null || currentAppServerCloudLet.isFinished(); boolean dbCloudletFinished = currentDBServerCloudLets == null || areAllCloudletsFinished(currentDBServerCloudLets); boolean appServerNextReady = !appServerCloudLets.isEmpty() && appServerCloudLets.peek().getIdealStartTime() <= currTime; boolean dbServerNextReady = !dbServerCloudLets.isEmpty() && getEarliestIdealStartTime(dbServerCloudLets.peek()) <= currTime; if (cloudletsLeft != 0 && appCloudletFinished && !dbCloudletFinished) { CustomLog.printf(Level.FINE, "Session %d in AS VM %d blocked in DB layer", getSessionId(), appVmId); } if (cloudletsLeft != 0 && appCloudletFinished && dbCloudletFinished && appServerNextReady && dbServerNextReady) { result = new StepCloudlets(appServerCloudLets.poll(), new ArrayList<>(dbServerCloudLets.poll())); currentAppServerCloudLet = result.asCloudlet; currentDBServerCloudLets = result.dbCloudlets; currentAppServerCloudLet.setVmId(appVmId); if (assignToServer(dbBalancer, currentDBServerCloudLets)) { currentAppServerCloudLet.setSessionId(getSessionId()); currentAppServerCloudLet.setUserId(userId); setSessionAndUserIds(getSessionId(), userId, currentDBServerCloudLets); cloudletsLeft--; if (Double.isNaN(startTime)) { startTime = Math.min(currentAppServerCloudLet.getIdealStartTime(), getEarliestIdealStartTime(currentDBServerCloudLets)); } } else { throw new SessionFailedException(sessionId, "The data for web session " + sessionId + " could not be found."); } } return result; }
WebSession { public StepCloudlets pollCloudlets(final double currTime) { StepCloudlets result = null; boolean appCloudletFinished = currentAppServerCloudLet == null || currentAppServerCloudLet.isFinished(); boolean dbCloudletFinished = currentDBServerCloudLets == null || areAllCloudletsFinished(currentDBServerCloudLets); boolean appServerNextReady = !appServerCloudLets.isEmpty() && appServerCloudLets.peek().getIdealStartTime() <= currTime; boolean dbServerNextReady = !dbServerCloudLets.isEmpty() && getEarliestIdealStartTime(dbServerCloudLets.peek()) <= currTime; if (cloudletsLeft != 0 && appCloudletFinished && !dbCloudletFinished) { CustomLog.printf(Level.FINE, "Session %d in AS VM %d blocked in DB layer", getSessionId(), appVmId); } if (cloudletsLeft != 0 && appCloudletFinished && dbCloudletFinished && appServerNextReady && dbServerNextReady) { result = new StepCloudlets(appServerCloudLets.poll(), new ArrayList<>(dbServerCloudLets.poll())); currentAppServerCloudLet = result.asCloudlet; currentDBServerCloudLets = result.dbCloudlets; currentAppServerCloudLet.setVmId(appVmId); if (assignToServer(dbBalancer, currentDBServerCloudLets)) { currentAppServerCloudLet.setSessionId(getSessionId()); currentAppServerCloudLet.setUserId(userId); setSessionAndUserIds(getSessionId(), userId, currentDBServerCloudLets); cloudletsLeft--; if (Double.isNaN(startTime)) { startTime = Math.min(currentAppServerCloudLet.getIdealStartTime(), getEarliestIdealStartTime(currentDBServerCloudLets)); } } else { throw new SessionFailedException(sessionId, "The data for web session " + sessionId + " could not be found."); } } return result; } }
WebSession { public StepCloudlets pollCloudlets(final double currTime) { StepCloudlets result = null; boolean appCloudletFinished = currentAppServerCloudLet == null || currentAppServerCloudLet.isFinished(); boolean dbCloudletFinished = currentDBServerCloudLets == null || areAllCloudletsFinished(currentDBServerCloudLets); boolean appServerNextReady = !appServerCloudLets.isEmpty() && appServerCloudLets.peek().getIdealStartTime() <= currTime; boolean dbServerNextReady = !dbServerCloudLets.isEmpty() && getEarliestIdealStartTime(dbServerCloudLets.peek()) <= currTime; if (cloudletsLeft != 0 && appCloudletFinished && !dbCloudletFinished) { CustomLog.printf(Level.FINE, "Session %d in AS VM %d blocked in DB layer", getSessionId(), appVmId); } if (cloudletsLeft != 0 && appCloudletFinished && dbCloudletFinished && appServerNextReady && dbServerNextReady) { result = new StepCloudlets(appServerCloudLets.poll(), new ArrayList<>(dbServerCloudLets.poll())); currentAppServerCloudLet = result.asCloudlet; currentDBServerCloudLets = result.dbCloudlets; currentAppServerCloudLet.setVmId(appVmId); if (assignToServer(dbBalancer, currentDBServerCloudLets)) { currentAppServerCloudLet.setSessionId(getSessionId()); currentAppServerCloudLet.setUserId(userId); setSessionAndUserIds(getSessionId(), userId, currentDBServerCloudLets); cloudletsLeft--; if (Double.isNaN(startTime)) { startTime = Math.min(currentAppServerCloudLet.getIdealStartTime(), getEarliestIdealStartTime(currentDBServerCloudLets)); } } else { throw new SessionFailedException(sessionId, "The data for web session " + sessionId + " could not be found."); } } return result; } WebSession(final IGenerator<? extends WebCloudlet> appServerCloudLets,
            final IGenerator<? extends Collection<? extends WebCloudlet>> dbServerCloudLets, final int userId,
            final int numberOfCloudlets, final double idealEnd, final String... metadata); }
WebSession { public StepCloudlets pollCloudlets(final double currTime) { StepCloudlets result = null; boolean appCloudletFinished = currentAppServerCloudLet == null || currentAppServerCloudLet.isFinished(); boolean dbCloudletFinished = currentDBServerCloudLets == null || areAllCloudletsFinished(currentDBServerCloudLets); boolean appServerNextReady = !appServerCloudLets.isEmpty() && appServerCloudLets.peek().getIdealStartTime() <= currTime; boolean dbServerNextReady = !dbServerCloudLets.isEmpty() && getEarliestIdealStartTime(dbServerCloudLets.peek()) <= currTime; if (cloudletsLeft != 0 && appCloudletFinished && !dbCloudletFinished) { CustomLog.printf(Level.FINE, "Session %d in AS VM %d blocked in DB layer", getSessionId(), appVmId); } if (cloudletsLeft != 0 && appCloudletFinished && dbCloudletFinished && appServerNextReady && dbServerNextReady) { result = new StepCloudlets(appServerCloudLets.poll(), new ArrayList<>(dbServerCloudLets.poll())); currentAppServerCloudLet = result.asCloudlet; currentDBServerCloudLets = result.dbCloudlets; currentAppServerCloudLet.setVmId(appVmId); if (assignToServer(dbBalancer, currentDBServerCloudLets)) { currentAppServerCloudLet.setSessionId(getSessionId()); currentAppServerCloudLet.setUserId(userId); setSessionAndUserIds(getSessionId(), userId, currentDBServerCloudLets); cloudletsLeft--; if (Double.isNaN(startTime)) { startTime = Math.min(currentAppServerCloudLet.getIdealStartTime(), getEarliestIdealStartTime(currentDBServerCloudLets)); } } else { throw new SessionFailedException(sessionId, "The data for web session " + sessionId + " could not be found."); } } return result; } WebSession(final IGenerator<? extends WebCloudlet> appServerCloudLets,
            final IGenerator<? extends Collection<? extends WebCloudlet>> dbServerCloudLets, final int userId,
            final int numberOfCloudlets, final double idealEnd, final String... metadata); String getSourceIP(); void setSourceIP(final String sourceIP); String getServerIP(); void setServerIP(final String serverIP); String[] getMetadata(); int getUserId(); void setUserId(final int userId); StepCloudlets pollCloudlets(final double currTime); void notifyOfTime(final double time); Integer getAppVmId(); void setAppVmId(final int appVmId); IDBBalancer getDbBalancer(); void setDbBalancer(final IDBBalancer dbBalancer); int getSessionId(); double getDelay(); double getFinishTime(); void setIdealEnd(final double idealEnd); double getIdealEnd(); double getStartTime(); String getReadableStartTime(); boolean isComplete(); boolean isFailed(); List<WebCloudlet> getFailedCloudlets(); boolean areVirtualMachinesReady(); }
WebSession { public StepCloudlets pollCloudlets(final double currTime) { StepCloudlets result = null; boolean appCloudletFinished = currentAppServerCloudLet == null || currentAppServerCloudLet.isFinished(); boolean dbCloudletFinished = currentDBServerCloudLets == null || areAllCloudletsFinished(currentDBServerCloudLets); boolean appServerNextReady = !appServerCloudLets.isEmpty() && appServerCloudLets.peek().getIdealStartTime() <= currTime; boolean dbServerNextReady = !dbServerCloudLets.isEmpty() && getEarliestIdealStartTime(dbServerCloudLets.peek()) <= currTime; if (cloudletsLeft != 0 && appCloudletFinished && !dbCloudletFinished) { CustomLog.printf(Level.FINE, "Session %d in AS VM %d blocked in DB layer", getSessionId(), appVmId); } if (cloudletsLeft != 0 && appCloudletFinished && dbCloudletFinished && appServerNextReady && dbServerNextReady) { result = new StepCloudlets(appServerCloudLets.poll(), new ArrayList<>(dbServerCloudLets.poll())); currentAppServerCloudLet = result.asCloudlet; currentDBServerCloudLets = result.dbCloudlets; currentAppServerCloudLet.setVmId(appVmId); if (assignToServer(dbBalancer, currentDBServerCloudLets)) { currentAppServerCloudLet.setSessionId(getSessionId()); currentAppServerCloudLet.setUserId(userId); setSessionAndUserIds(getSessionId(), userId, currentDBServerCloudLets); cloudletsLeft--; if (Double.isNaN(startTime)) { startTime = Math.min(currentAppServerCloudLet.getIdealStartTime(), getEarliestIdealStartTime(currentDBServerCloudLets)); } } else { throw new SessionFailedException(sessionId, "The data for web session " + sessionId + " could not be found."); } } return result; } WebSession(final IGenerator<? extends WebCloudlet> appServerCloudLets,
            final IGenerator<? extends Collection<? extends WebCloudlet>> dbServerCloudLets, final int userId,
            final int numberOfCloudlets, final double idealEnd, final String... metadata); String getSourceIP(); void setSourceIP(final String sourceIP); String getServerIP(); void setServerIP(final String serverIP); String[] getMetadata(); int getUserId(); void setUserId(final int userId); StepCloudlets pollCloudlets(final double currTime); void notifyOfTime(final double time); Integer getAppVmId(); void setAppVmId(final int appVmId); IDBBalancer getDbBalancer(); void setDbBalancer(final IDBBalancer dbBalancer); int getSessionId(); double getDelay(); double getFinishTime(); void setIdealEnd(final double idealEnd); double getIdealEnd(); double getStartTime(); String getReadableStartTime(); boolean isComplete(); boolean isFailed(); List<WebCloudlet> getFailedCloudlets(); boolean areVirtualMachinesReady();  }