List of usage examples for java.util ArrayList iterator
public Iterator<E> iterator()
From source file:br.org.indt.ndg.server.survey.SurveyHandlerBean.java
@Override public void updateStatusSendingSurvey(String imei, String status) throws MSMApplicationException, MSMSystemException { Query q = manager.createQuery("from Transactionlog where transactionType = " + "\'" + TransactionLogVO.TYPE_SEND_SURVEY + "\' " + "and imei.imei = :imei " + "and transactionStatus = \'" + TransactionLogVO.STATUS_AVAILABLE + "\'"); q.setParameter("imei", imei); ArrayList<Transactionlog> arraySurveyTransactionLog = (ArrayList<Transactionlog>) q.getResultList(); Iterator<Transactionlog> it = arraySurveyTransactionLog.iterator(); while (it.hasNext()) { // SurveyTransactionLog log = (SurveyTransactionLog) it.next(); Transactionlog log = manager.find(Transactionlog.class, ((Transactionlog) it.next()).getIdTransactionLog()); if (log == null) { throw new TransactionLogNotFoundException(); }/*from ww w . jav a2 s . c om*/ System.out.println(">>>>> SurveyTransactioneLog: " + log.getImei() + " - " + log.getTransactionStatus() + " - " + log.getSurvey().getIdSurvey()); log.setTransactionStatus(status); manager.persist(log); } }
From source file:br.gov.lexml.oaicat.LexMLOAICatalog.java
private Map internalListRecords(final List<RegistroItem> ri_list, final InternalResumptionToken irt) throws CannotDisseminateFormatException, NoItemsMatchException { purge(); // clean out old resumptionTokens Map listRecordsMap = new HashMap(); ArrayList records = new ArrayList(); int numRows = ri_list.size(); Iterator<RegistroItem> ri_iter = ri_list.iterator(); if (numRows == 0) { throw new NoItemsMatchException(); }/*from w ww . j ava 2 s. c o m*/ while (ri_iter.hasNext()) { records.add(constructRecord(ri_iter.next(), irt.format)); } // Verifica se temos que informar um ResumptionToken if (numRows >= maxListSize) { String resumptionId = LexMLOAICatalog.getRSName(); String lastId = getLastId(ri_list); InternalResumptionToken novoIRT = new InternalResumptionToken(irt, lastId, numRows); resumptionTokens.put(resumptionId, novoIRT); listRecordsMap.put("resumptionMap", getResumptionMap(resumptionId, irt.total, irt.offset)); } listRecordsMap.put("records", records.iterator()); return listRecordsMap; }
From source file:br.org.indt.ndg.server.survey.SurveyHandlerBean.java
public QueryInputOutputVO listSurveysByImeiDBWithoutResults(String imei, String status, QueryInputOutputVO queryIOVO) throws MSMApplicationException, MSMSystemException { if (queryIOVO == null) { queryIOVO = new QueryInputOutputVO(); }/*from w ww . j ava 2 s.c o m*/ NdgUser user = businessDelegate.getUserByImei(imei); String sqlCommand = "from Transactionlog t where transactionType = " + "\'" + TransactionLogVO.TYPE_SEND_SURVEY + "\' " + "and imei.imei = :imei " + "and transactionStatus = :status "; if ((queryIOVO.getFilterText() != null) && (queryIOVO.getFilterFields() != null)) { sqlCommand += SqlUtil.getFilterCondition(queryIOVO.getFilterText(), queryIOVO.getFilterFields()); } sqlCommand += " group by t.survey.idSurvey "; if ((queryIOVO.getSortField() != null) && (queryIOVO.getIsDescending() != null)) { sqlCommand += SqlUtil.getSortCondition(queryIOVO.getSortField(), queryIOVO.getIsDescending()); } Query q = manager.createQuery(sqlCommand); q.setParameter("imei", imei); q.setParameter("status", status); queryIOVO.setRecordCount(q.getResultList().size()); if ((queryIOVO.getPageNumber() != null) && (queryIOVO.getRecordsPerPage() != null)) { q.setFirstResult((queryIOVO.getPageNumber() - 1) * queryIOVO.getRecordsPerPage()); q.setMaxResults(queryIOVO.getRecordsPerPage()); } ArrayList<Transactionlog> al = (ArrayList<Transactionlog>) q.getResultList(); Iterator<Transactionlog> it = al.iterator(); ArrayList<Object> surveyList = new ArrayList<Object>(); while (it.hasNext()) { SurveyXML survey = null; Transactionlog surveyTransactionLog = (Transactionlog) it.next(); SurveyVO vo = new SurveyVO(); vo.setIdSurvey(surveyTransactionLog.getSurvey().getIdSurvey()); survey = loadSurveyDB(user.getUserAdmin(), surveyTransactionLog.getSurvey().getIdSurvey()); CreateXml.xmlToString(survey.getXmldoc()); Survey surveyPojo = manager.find(Survey.class, surveyTransactionLog.getSurvey().getIdSurvey()); try { byte[] stringXMLByte = surveyPojo.getSurveyXml().getBytes("UTF-8"); vo.setSurvey(new String(stringXMLByte, "UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } vo.setTitle(survey.getTitle()); vo.setResultsSent(survey.getResultsSize()); vo.setStatus(surveyTransactionLog.getTransactionStatus()); surveyList.add(vo); } queryIOVO.setQueryResult(surveyList); return queryIOVO; }
From source file:br.org.indt.ndg.server.survey.SurveyHandlerBean.java
public QueryInputOutputVO getAllImeisBySurvey(String surveyId, QueryInputOutputVO queryIOVO) throws MSMApplicationException { if (queryIOVO == null) { queryIOVO = new QueryInputOutputVO(); }/* w w w . jav a 2s. co m*/ String sQuery = "from Transactionlog where transactionType = "; sQuery += "\'"; sQuery += TransactionLogVO.TYPE_SEND_SURVEY; sQuery += "\'"; sQuery += " and survey.idSurvey = :surveyId"; if ((queryIOVO.getFilterText() != null) && (queryIOVO.getFilterFields() != null)) { sQuery += SqlUtil.getFilterCondition(queryIOVO.getFilterText(), queryIOVO.getFilterFields()); } if ((queryIOVO.getSortField() != null) && (queryIOVO.getIsDescending() != null)) { sQuery += SqlUtil.getSortCondition(queryIOVO.getSortField(), queryIOVO.getIsDescending()); } Query q = manager.createQuery(sQuery); q.setParameter("surveyId", surveyId); if ((queryIOVO.getPageNumber() != null) && (queryIOVO.getRecordsPerPage() != null)) { q.setFirstResult((queryIOVO.getPageNumber() - 1) * queryIOVO.getRecordsPerPage()); q.setMaxResults(queryIOVO.getRecordsPerPage()); } ArrayList<Object> ret = new ArrayList<Object>(); ArrayList<Transactionlog> al = (ArrayList<Transactionlog>) q.getResultList(); Iterator<Transactionlog> it = al.iterator(); ArrayList<String> imeiIdListAux = new ArrayList<String>(); while (it.hasNext()) { Transactionlog surveyTransactionLog = (Transactionlog) it.next(); if (imeiIdListAux.contains(surveyTransactionLog.getImei().getImei())) { continue; } imeiIdListAux.add(surveyTransactionLog.getImei().getImei()); Imei imei = null; if (surveyTransactionLog.getImei() != null) { imei = manager.find(Imei.class, surveyTransactionLog.getImei().getImei()); } if (imei != null) { ImeiVO vo = new ImeiVO(); vo.setImei(imei.getImei()); vo.setMsisdn(imei.getMsisdn()); vo.setUserName(imei.getUser().getUsername()); NdgDevice device = imei.getDevice(); DeviceVO devVO = new DeviceVO(); devVO.setIdDevice(device.getIdDevice()); devVO.setDeviceModel(device.getDeviceModel()); vo.setDevice(devVO); vo.setRealImei(imei.getRealImei()); if (!surveyTransactionLog.getTransactionStatus().equals(TransactionLogVO.STATUS_SUCCESS)) { vo.setStatus(TransactionLogVO.STATUS_PENDING); } else { vo.setStatus(surveyTransactionLog.getTransactionStatus()); } StringBuilder builder = new StringBuilder(); builder.append("from Result where idSurvey = '"); builder.append(surveyId); builder.append("' and imei = '"); builder.append(vo.getImei()); builder.append("'"); Query query = manager.createQuery(builder.toString()); vo.setQtdeResults(query.getResultList().size()); ret.add(vo); } } queryIOVO.setRecordCount(ret.size()); queryIOVO.setQueryResult(ret); return queryIOVO; }
From source file:br.org.indt.ndg.server.survey.SurveyHandlerBean.java
public QueryInputOutputVO getImeisBySurvey(String surveyId, String status, QueryInputOutputVO queryIOVO) throws MSMApplicationException { if (queryIOVO == null) { queryIOVO = new QueryInputOutputVO(); }/* w ww . j a v a 2s. co m*/ String sQuery = "from Transactionlog where transactionType = "; sQuery += "\'"; sQuery += TransactionLogVO.TYPE_SEND_SURVEY; sQuery += "\'"; sQuery += " and survey.idSurvey = :surveyId and transactionStatus = :status"; // PENDING is all that was not downloaded yet (may be PENDING or // AVAILABLE, any status that is not SUCCESS) if ((status != null) && status.equals(TransactionLogVO.STATUS_PENDING)) { sQuery = ""; sQuery += "from Transactionlog where transactionType = "; sQuery += "\'"; sQuery += TransactionLogVO.TYPE_SEND_SURVEY; sQuery += "\'"; sQuery += " and survey.idSurvey = :surveyId and NOT(transactionStatus = " + "\'" + TransactionLogVO.STATUS_SUCCESS + "\')"; } if ((queryIOVO.getFilterText() != null) && (queryIOVO.getFilterFields() != null)) { sQuery += SqlUtil.getFilterCondition(queryIOVO.getFilterText(), queryIOVO.getFilterFields()); } if ((queryIOVO.getSortField() != null) && (queryIOVO.getIsDescending() != null)) { sQuery += SqlUtil.getSortCondition(queryIOVO.getSortField(), queryIOVO.getIsDescending()); } Query q = manager.createQuery(sQuery); q.setParameter("surveyId", surveyId); // if it is not PENDING 'status' parameter is used if ((status != null) && (!status.equals(TransactionLogVO.STATUS_PENDING))) { q.setParameter("status", status); } queryIOVO.setRecordCount(q.getResultList().size()); if ((queryIOVO.getPageNumber() != null) && (queryIOVO.getRecordsPerPage() != null)) { q.setFirstResult((queryIOVO.getPageNumber() - 1) * queryIOVO.getRecordsPerPage()); q.setMaxResults(queryIOVO.getRecordsPerPage()); } ArrayList<Object> ret = new ArrayList<Object>(); ArrayList<Transactionlog> al = (ArrayList<Transactionlog>) q.getResultList(); Iterator<Transactionlog> it = al.iterator(); while (it.hasNext()) { Transactionlog surveyTransactionLog = (Transactionlog) it.next(); Imei imei = null; if (surveyTransactionLog.getImei() != null) { imei = manager.find(Imei.class, surveyTransactionLog.getImei().getImei()); System.out.println("####### SurveyTransactionLog: IMEI = " + surveyTransactionLog.getImei()); } if (imei != null) { ImeiVO vo = new ImeiVO(); vo.setImei(imei.getImei()); vo.setMsisdn(imei.getMsisdn()); vo.setUserName(imei.getUser().getUsername()); NdgDevice device = imei.getDevice(); DeviceVO devVO = new DeviceVO(); devVO.setIdDevice(device.getIdDevice()); devVO.setDeviceModel(device.getDeviceModel()); vo.setDevice(devVO); vo.setRealImei(imei.getRealImei()); if (!surveyTransactionLog.getTransactionStatus().equals(TransactionLogVO.STATUS_SUCCESS)) { vo.setStatus(TransactionLogVO.STATUS_PENDING); } else { vo.setStatus(surveyTransactionLog.getTransactionStatus()); } ret.add(vo); } } queryIOVO.setQueryResult(ret); return queryIOVO; }
From source file:br.org.indt.ndg.server.survey.SurveyHandlerBean.java
@Override public ArrayList<String> rationSurveybyGPRS(NdgUser userlogged, String idSurvey, ArrayList<String> listOfDevices) throws MSMApplicationException, MSMSystemException { ArrayList<String> devicesToGetNewSurvey = new ArrayList<String>(); for (Iterator<String> iterator = listOfDevices.iterator(); iterator.hasNext();) { String deviceIMEI = iterator.next(); InitialContext initialContext = null; TransactionLogManager transactionlogManager = null; try {/*from ww w .j av a 2s. co m*/ initialContext = new InitialContext(); transactionlogManager = (TransactionLogManager) initialContext .lookup("ndg-core/TransactionLogManagerBean/remote"); } catch (NamingException e) { new SurveyRationException(); } if (!transactionlogManager.existTransactionLog(TransactionLogVO.TYPE_SEND_SURVEY, idSurvey, TransactionLogVO.STATUS_AVAILABLE, TransactionLogVO.MODE_GPRS, deviceIMEI)) { TransactionLogVO t = new TransactionLogVO(); t.setUser(userlogged.getUsername()); t.setDtLog(new Timestamp(System.currentTimeMillis())); t.setTransmissionMode(TransactionLogVO.MODE_GPRS); t.setStatus(TransactionLogVO.STATUS_AVAILABLE); t.setTransactionType(TransactionLogVO.TYPE_SEND_SURVEY); t.setImei(deviceIMEI); t.setSurveyId(idSurvey); if (transactionlogManager != null) { transactionlogManager.logTransaction(t); } devicesToGetNewSurvey.add(deviceIMEI); } } return devicesToGetNewSurvey; }
From source file:fr.inria.oak.paxquery.pact.operations.xml.navigation.SingleDocumentExtractor.java
/** * This method eliminates the match em, its children and descendants, in other * stacks and in the same stack, from their respective stacks. * // ww w . j ava 2 s .c om * @param em * @param s */ private void recursivePop(ExtractorMatch em, ExtractorMatchStack s) { if (em.childrenByStack == null) { eliminate(s, em); } if (em.childrenByStack.size() == 0) { eliminate(s, em); } Iterator<ExtractorMatchStack> it = em.childrenByStack.keySet().iterator(); while (it.hasNext()) { ExtractorMatchStack s2 = it.next(); ArrayList<ExtractorMatch> v2 = em.childrenByStack.get(s2); if (v2 != null) { Iterator<ExtractorMatch> it3 = v2.iterator(); while (it3.hasNext()) { ExtractorMatch em3 = it3.next(); recursivePop(em3, s2); } } } Iterator<ExtractorMatch> itc = em.ownChildren.iterator(); while (itc.hasNext()) { ExtractorMatch em4 = itc.next(); recursivePop(em4, s); } }
From source file:com.apkcategorychecker.json.DefaultJsCSVBuilder.java
@Override public void BuildJs(ArrayList<JsElement> jsList, String _destinationPath, String time) { try {/*from ww w. ja va 2 s . c o m*/ /*Check if _destinationPath is an APK or a Directory in order to *get the right destination path */ File Destination = new File(_destinationPath); if (!Destination.exists()) { Destination.mkdir(); } if (Destination.isDirectory()) { this._destPath = _destinationPath; } else if (Destination.isFile()) { this._destPath = _destinationPath.substring(0, _destinationPath.length() - 4); } /*--Create the CSVFormat object--*/ CSVFormat format = CSVFormat.EXCEL.withHeader().withDelimiter(','); /*--Writing in a CSV file--*/ File _fileCSV = new File(_destPath + "/Results-JS FILES_" + time + ".csv"); FileWriter _out = new FileWriter(_fileCSV); CSVPrinter printer; printer = new CSVPrinter(_out, format.withDelimiter('#')); System.out.println("Creating " + "Results-JS FILES_" + time + ".csv ...."); try { printer.printRecord("appID", "jsFiles"); } catch (IOException ex) { Logger.getLogger(WriterCSV.class.getName()).log(Level.SEVERE, null, ex); } /*--Retrieve APKResult and Write in file--*/ @SuppressWarnings("unused") int i = 0; Iterator<JsElement> it = jsList.iterator(); while (it.hasNext()) { JsElement _resultElement = it.next(); List<String> resultData = new ArrayList<>(); resultData.add(_resultElement.get_Id()); resultData.add(_resultElement.get_JsFiles()); i++; printer.printRecord(resultData); } /*--Close the printer--*/ printer.close(); System.out.println("Results-JS FILES_" + time + ".csv created"); } catch (IOException ex) { Logger.getLogger(WriterCSV.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.datatorrent.stram.engine.GenericNode.java
/** * Originally this method was defined in an attempt to implement the interface Runnable. * * Note that activate does not return as long as there is useful workload for the node. *///from w w w . jav a 2s. c o m @Override @SuppressWarnings({ "SleepWhileInLoop", "UseSpecificCatch", "BroadCatchBlock", "TooBroadCatch" }) public final void run() { doCheckpoint = false; final long maxSpinMillis = context.getValue(OperatorContext.SPIN_MILLIS); long spinMillis = 0; final boolean handleIdleTime = operator instanceof IdleTimeHandler; int totalQueues = inputs.size(); int regularQueues = totalQueues; // regularQueues is the number of queues that are not connected to a DelayOperator for (String portName : inputs.keySet()) { if (isInputPortConnectedToDelayOperator(portName)) { regularQueues--; } } ArrayList<Map.Entry<String, SweepableReservoir>> activeQueues = new ArrayList<>(); activeQueues.addAll(inputs.entrySet()); int expectingBeginWindow = activeQueues.size(); int receivedEndWindow = 0; long firstWindowId = -1; calculateNextCheckpointWindow(); TupleTracker tracker; LinkedList<TupleTracker> resetTupleTracker = new LinkedList<TupleTracker>(); try { do { Iterator<Map.Entry<String, SweepableReservoir>> buffers = activeQueues.iterator(); activequeue: while (buffers.hasNext()) { Map.Entry<String, SweepableReservoir> activePortEntry = buffers.next(); SweepableReservoir activePort = activePortEntry.getValue(); Tuple t = activePort.sweep(); if (t != null) { spinMillis = 0; boolean delay = (operator instanceof Operator.DelayOperator); long windowAhead = 0; if (delay) { windowAhead = WindowGenerator.getAheadWindowId(t.getWindowId(), firstWindowMillis, windowWidthMillis, 1); } switch (t.getType()) { case BEGIN_WINDOW: if (expectingBeginWindow == totalQueues) { // This is the first begin window tuple among all ports if (isInputPortConnectedToDelayOperator(activePortEntry.getKey())) { // We need to wait for the first BEGIN_WINDOW from a port not connected to DelayOperator before // we can do anything with it, because otherwise if a CHECKPOINT tuple arrives from // upstream after the BEGIN_WINDOW tuple for the next window from the delay operator, it would end // up checkpointing in the middle of the window. This code is assuming we have at least one // input port that is not connected to a DelayOperator, and we might have to change this later. // In the future, this condition will not be needed if we get rid of the CHECKPOINT tuple. continue; } activePort.remove(); expectingBeginWindow--; receivedEndWindow = 0; currentWindowId = t.getWindowId(); if (delay) { if (WindowGenerator.getBaseSecondsFromWindowId(windowAhead) > t .getBaseSeconds()) { // Buffer server code strips out the base seconds from BEGIN_WINDOW and END_WINDOW tuples for // serialization optimization. That's why we need a reset window here to tell the buffer // server we are having a new baseSeconds now. Tuple resetWindowTuple = new ResetWindowTuple(windowAhead); for (int s = sinks.length; s-- > 0;) { sinks[s].put(resetWindowTuple); } controlTupleCount++; } t.setWindowId(windowAhead); } for (int s = sinks.length; s-- > 0;) { sinks[s].put(t); } controlTupleCount++; context.setWindowsFromCheckpoint(nextCheckpointWindowCount--); if (applicationWindowCount == 0) { insideWindow = true; operator.beginWindow(currentWindowId); } } else if (t.getWindowId() == currentWindowId) { activePort.remove(); expectingBeginWindow--; } else { buffers.remove(); String port = activePortEntry.getKey(); if (PROCESSING_MODE == ProcessingMode.AT_MOST_ONCE) { if (t.getWindowId() < currentWindowId) { /* * we need to fast forward this stream till we find the current * window or the window which is bigger than the current window. */ /* lets move the current reservoir in the background */ Sink<Object> sink = activePort.setSink(Sink.BLACKHOLE); deferredInputConnections.add(0, new DeferredInputConnection(port, activePort)); /* replace it with the reservoir which blocks the tuples in the past */ WindowIdActivatedReservoir wiar = new WindowIdActivatedReservoir(port, activePort, currentWindowId); wiar.setSink(sink); inputs.put(port, wiar); activeQueues.add(new AbstractMap.SimpleEntry<String, SweepableReservoir>( port, wiar)); break activequeue; } else { expectingBeginWindow--; if (++receivedEndWindow == totalQueues) { processEndWindow(null); activeQueues.addAll(inputs.entrySet()); expectingBeginWindow = activeQueues.size(); break activequeue; } } } else { logger.error( "Catastrophic Error: Out of sequence {} tuple {} on port {} while expecting {}", t.getType(), Codec.getStringWindowId(t.getWindowId()), port, Codec.getStringWindowId(currentWindowId)); System.exit(2); } } break; case END_WINDOW: buffers.remove(); if (t.getWindowId() == currentWindowId) { activePort.remove(); endWindowDequeueTimes.put(activePort, System.currentTimeMillis()); if (++receivedEndWindow == totalQueues) { assert (activeQueues.isEmpty()); if (delay) { t.setWindowId(windowAhead); } processEndWindow(t); activeQueues.addAll(inputs.entrySet()); expectingBeginWindow = activeQueues.size(); break activequeue; } } break; case CHECKPOINT: activePort.remove(); long checkpointWindow = t.getWindowId(); if (lastCheckpointWindowId < checkpointWindow) { dagCheckpointOffsetCount = 0; if (PROCESSING_MODE == ProcessingMode.EXACTLY_ONCE) { lastCheckpointWindowId = checkpointWindow; } else if (!doCheckpoint) { if (checkpointWindowCount == 0) { checkpoint(checkpointWindow); lastCheckpointWindowId = checkpointWindow; } else { doCheckpoint = true; } } if (!delay) { for (int s = sinks.length; s-- > 0;) { sinks[s].put(t); } controlTupleCount++; } } break; case RESET_WINDOW: /** * we will receive tuples which are equal to the number of input streams. */ activePort.remove(); if (isInputPortConnectedToDelayOperator(activePortEntry.getKey())) { break; // breaking out of the switch/case } buffers.remove(); int baseSeconds = t.getBaseSeconds(); tracker = null; for (Iterator<TupleTracker> trackerIterator = resetTupleTracker .iterator(); trackerIterator.hasNext();) { tracker = trackerIterator.next(); if (tracker.tuple.getBaseSeconds() == baseSeconds) { break; } } if (tracker == null) { tracker = new TupleTracker(t, regularQueues); resetTupleTracker.add(tracker); } int trackerIndex = 0; while (trackerIndex < tracker.ports.length) { if (tracker.ports[trackerIndex] == null) { tracker.ports[trackerIndex++] = activePort; break; } else if (tracker.ports[trackerIndex] == activePort) { break; } trackerIndex++; } if (trackerIndex == regularQueues) { Iterator<TupleTracker> trackerIterator = resetTupleTracker.iterator(); while (trackerIterator.hasNext()) { if (trackerIterator.next().tuple.getBaseSeconds() <= baseSeconds) { trackerIterator.remove(); } } if (!delay) { for (int s = sinks.length; s-- > 0;) { sinks[s].put(t); } controlTupleCount++; } if (!activeQueues.isEmpty()) { // make sure they are all queues from DelayOperator for (Map.Entry<String, SweepableReservoir> entry : activeQueues) { if (!isInputPortConnectedToDelayOperator(entry.getKey())) { assert (false); } } activeQueues.clear(); } activeQueues.addAll(inputs.entrySet()); expectingBeginWindow = activeQueues.size(); if (firstWindowId == -1) { if (delay) { for (int s = sinks.length; s-- > 0;) { sinks[s].put(t); } controlTupleCount++; // if it's a DelayOperator and this is the first RESET_WINDOW (start) or END_STREAM // (recovery), fabricate the first window fabricateFirstWindow((Operator.DelayOperator) operator, windowAhead); } firstWindowId = t.getWindowId(); } break activequeue; } break; case END_STREAM: activePort.remove(); buffers.remove(); if (firstWindowId == -1) { // this is for recovery from a checkpoint for DelayOperator if (delay) { // if it's a DelayOperator and this is the first RESET_WINDOW (start) or END_STREAM (recovery), // fabricate the first window fabricateFirstWindow((Operator.DelayOperator) operator, windowAhead); } firstWindowId = t.getWindowId(); } for (Iterator<Entry<String, SweepableReservoir>> it = inputs.entrySet().iterator(); it .hasNext();) { Entry<String, SweepableReservoir> e = it.next(); if (e.getValue() == activePort) { if (!descriptor.inputPorts.isEmpty()) { descriptor.inputPorts.get(e.getKey()).component.setConnected(false); } it.remove(); /* check the deferred connection list for any new port that should be connected here */ Iterator<DeferredInputConnection> dici = deferredInputConnections.iterator(); while (dici.hasNext()) { DeferredInputConnection dic = dici.next(); if (e.getKey().equals(dic.portname)) { connectInputPort(dic.portname, dic.reservoir); dici.remove(); activeQueues.add( new AbstractMap.SimpleEntry<>(dic.portname, dic.reservoir)); break activequeue; } } break; } } /** * We are not going to receive begin window on this ever! */ expectingBeginWindow--; /** * Since one of the operators we care about it gone, we should relook at our ports. * We need to make sure that the END_STREAM comes outside of the window. */ regularQueues--; totalQueues--; boolean break_activequeue = false; if (regularQueues == 0) { alive = false; break_activequeue = true; } else if (activeQueues.isEmpty()) { assert (!inputs.isEmpty()); processEndWindow(null); activeQueues.addAll(inputs.entrySet()); expectingBeginWindow = activeQueues.size(); break_activequeue = true; } /** * also make sure that we update the reset tuple tracker if this stream had delivered any reset tuples. * Check all the reset buffers to see if current input port has already delivered reset tuple. If it has * then we are waiting for something else to deliver the reset tuple, so just clear current reservoir * from the list of tracked reservoirs. If the current input port has not delivered the reset tuple, and * it's the only one which has not, then we consider it delivered and release the reset tuple downstream. */ Tuple tuple = null; for (Iterator<TupleTracker> trackerIterator = resetTupleTracker .iterator(); trackerIterator.hasNext();) { tracker = trackerIterator.next(); trackerIndex = 0; while (trackerIndex < tracker.ports.length) { if (tracker.ports[trackerIndex] == activePort) { SweepableReservoir[] ports = new SweepableReservoir[regularQueues]; System.arraycopy(tracker.ports, 0, ports, 0, trackerIndex); if (trackerIndex < regularQueues) { System.arraycopy(tracker.ports, trackerIndex + 1, ports, trackerIndex, tracker.ports.length - trackerIndex - 1); } tracker.ports = ports; break; } else if (tracker.ports[trackerIndex] == null) { if (trackerIndex == regularQueues) { /* regularQueues is already adjusted above */ if (tuple == null || tuple.getBaseSeconds() < tracker.tuple.getBaseSeconds()) { tuple = tracker.tuple; } trackerIterator.remove(); } break; } else { tracker.ports = Arrays.copyOf(tracker.ports, regularQueues); } trackerIndex++; } } /* * Since we were waiting for a reset tuple on this stream, we should not any longer. */ if (tuple != null && !delay) { for (int s = sinks.length; s-- > 0;) { sinks[s].put(tuple); } controlTupleCount++; } if (break_activequeue) { break activequeue; } break; default: throw new UnhandledException("Unrecognized Control Tuple", new IllegalArgumentException(t.toString())); } } } if (activeQueues.isEmpty() && alive) { logger.error("Catastrophic Error: Invalid State - the operator blocked forever!"); System.exit(2); } else { boolean need2sleep = true; for (Map.Entry<String, SweepableReservoir> cb : activeQueues) { need2sleep = cb.getValue().isEmpty(); if (!need2sleep) { spinMillis = 0; break; } } if (need2sleep) { if (handleIdleTime && insideWindow) { ((IdleTimeHandler) operator).handleIdleTime(); } else { Thread.sleep(spinMillis); spinMillis = Math.min(maxSpinMillis, spinMillis + 1); } } } } while (alive); } catch (ShutdownException se) { logger.debug("Shutdown requested by the operator when alive = {}.", alive); alive = false; } catch (Throwable cause) { synchronized (this) { if (alive) { DTThrowable.rethrow(cause); } } Throwable rootCause = cause; while (rootCause != null) { if (rootCause instanceof InterruptedException) { break; } rootCause = rootCause.getCause(); } if (rootCause == null) { DTThrowable.rethrow(cause); } else { logger.debug("Ignoring InterruptedException after shutdown", cause); } } /** * TODO: If shutdown and inside window provide alternate way of notifying the operator in such ways * TODO: as using a listener callback */ if (insideWindow && !shutdown) { operator.endWindow(); endWindowEmitTime = System.currentTimeMillis(); if (++applicationWindowCount == APPLICATION_WINDOW_COUNT) { applicationWindowCount = 0; } if (++checkpointWindowCount == CHECKPOINT_WINDOW_COUNT) { checkpointWindowCount = 0; if (doCheckpoint || PROCESSING_MODE == ProcessingMode.EXACTLY_ONCE) { checkpoint(currentWindowId); } } ContainerStats.OperatorStats stats = new ContainerStats.OperatorStats(); fixEndWindowDequeueTimesBeforeDeactivate(); reportStats(stats, currentWindowId); stats.metrics = collectMetrics(); handleRequests(currentWindowId); } }
From source file:com.skilrock.lms.web.scratchService.gameMgmt.common.GameUploadAction.java
public void VirnUploadGameNameAjax() { PrintWriter out;// ww w. j av a 2 s . c om try { out = getResponse().getWriter(); String game_type = getGameType(); System.out.println("" + game_type); if (game_type == null) { game_type = ""; } GameuploadHelper gameuploadHelper = new GameuploadHelper(); ArrayList<GameBean> game = gameuploadHelper.fatchVirnGameList(game_type); String html = ""; html = "<select class=\"option\" name=\"gameName\" id=\"game_Name\" onchange=\"gameDatesfromDB()\"><option class=\"option\" value=\"Please Select\">Please Select</option>"; int i = 0; GameBean bean = null; for (Iterator<GameBean> it = game.iterator(); it.hasNext();) { bean = it.next(); String name = bean.getGameName(); i++; html += "<option class=\"option\" value=\"" + name + "\">" + name + "</option>"; } html += "</select>"; response.setContentType("text/html"); out.print(html); System.out.println(html); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }