List of usage examples for java.util LinkedList getLast
public E getLast()
From source file:org.jboss.as.test.integration.logging.perdeploy.Log4jPropertiesTestCase.java
@Test public void testDeploymentConfigurationResource() throws Exception { final ModelNode loggingConfiguration = readDeploymentResource(DEPLOYMENT_NAME); // The address should have jboss-log4j.xml final LinkedList<Property> resultAddress = new LinkedList<>( Operations.getOperationAddress(loggingConfiguration).asPropertyList()); Assert.assertTrue("The configuration path did not include log4j.properties", resultAddress.getLast().getValue().asString().contains("log4j.properties")); Assert.assertTrue(loggingConfiguration.has("handler")); // A log4j configuration cannot be defined in the model Assert.assertFalse("No handlers should be defined", loggingConfiguration.get("handler").isDefined()); }
From source file:org.jboss.as.test.integration.logging.perdeploy.LoggingPropertiesTestCase.java
@Test public void testDeploymentConfigurationResource() throws Exception { final ModelNode loggingConfiguration = readDeploymentResource(DEPLOYMENT_NAME); // The address should have jboss-log4j.xml final LinkedList<Property> resultAddress = new LinkedList<>( Operations.getOperationAddress(loggingConfiguration).asPropertyList()); Assert.assertTrue("The configuration path did not include logging.properties", resultAddress.getLast().getValue().asString().contains("logging.properties")); final ModelNode handler = loggingConfiguration.get("handler", "FILE"); Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined()); Assert.assertTrue(handler.hasDefined("properties")); String fileName = null;/* w w w . ja v a2 s.c om*/ // Find the fileName property for (Property property : handler.get("properties").asPropertyList()) { if ("fileName".equals(property.getName())) { fileName = property.getValue().asString(); break; } } Assert.assertNotNull("fileName property not found", fileName); Assert.assertTrue(fileName.endsWith("logging-properties-test.log")); }
From source file:org.jboss.as.test.integration.logging.perdeploy.JBossLoggingPropertiesTestCase.java
@Test public void testDeploymentConfigurationResource() throws Exception { final ModelNode loggingConfiguration = readDeploymentResource(DEPLOYMENT_NAME); // The address should have jboss-log4j.xml final LinkedList<Property> resultAddress = new LinkedList<>( Operations.getOperationAddress(loggingConfiguration).asPropertyList()); Assert.assertTrue("The configuration path did not include jboss-logging.properties", resultAddress.getLast().getValue().asString().contains("jboss-logging.properties")); final ModelNode handler = loggingConfiguration.get("handler", "FILE"); Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined()); Assert.assertTrue(handler.hasDefined("properties")); String fileName = null;//from ww w . j a v a2 s . co m // Find the fileName property for (Property property : handler.get("properties").asPropertyList()) { if ("fileName".equals(property.getName())) { fileName = property.getValue().asString(); break; } } Assert.assertNotNull("fileName property not found", fileName); Assert.assertTrue(fileName.endsWith("jboss-logging-properties-test.log")); }
From source file:pl.otros.logview.gui.message.StackTraceFinder.java
public SortedSet<SubText> findStackTraces(String text) { SortedSet<SubText> set = new TreeSet<SubText>(); LinkedList<Integer> newLineIndexes = new LinkedList<Integer>(); newLineIndexes.add(0);//from w ww.ja va 2s .c o m int newLineIndex = -1; while ((newLineIndex = StringUtils.indexOf(text, '\n', newLineIndex + 1)) > -1) { newLineIndexes.addLast(newLineIndex); } if (newLineIndexes.getLast() < text.length()) { newLineIndexes.addLast(text.length()); } int startLine; int endLine; boolean found = false; int startedLineException = -1; for (int i = 0; i < newLineIndexes.size() - 1; i++) { startLine = newLineIndexes.get(i); endLine = newLineIndexes.get(i + 1); String line = text.substring(startLine, endLine); Matcher matcher = exceptionLine.matcher(line); boolean f = matcher.find(); if (f && !found) { startedLineException = i - 1; } else if (!f && found) { // exception end int start = newLineIndexes.get(startedLineException); int end = newLineIndexes.get(i); SubText subText = new SubText(start, end); set.add(subText); } found = f; } // Add stacktrace if string with end of stacktrace if (found) { int start = newLineIndexes.get(startedLineException); int end = newLineIndexes.getLast(); SubText subText = new SubText(start, end); set.add(subText); } // for (SubText subText : set) { // System.out.printf("[%d -> %d] \n\"%s\"", subText.start, subText.end, text.substring(subText.start, subText.end)); // } return set; }
From source file:org.matsim.contrib.analysis.christoph.ActivitiesAnalyzer.java
private void changeCount(double time, LinkedList<ActivityData> list, int delta) { ActivityData activityData = list.getLast(); /*/*w w w . j a v a2 s. co m*/ * If there is already another entry for the same time step, re-use it. * Otherwise create a new one. */ if (time == activityData.time) { activityData.activityCount += delta; } else { list.add(new ActivityData(time, activityData.activityCount + delta)); } }
From source file:org.toobsframework.transformpipeline.domain.TraceListenerImpl.java
public void traceEnd(TracerEvent ev) { long time = System.currentTimeMillis(); String key = _traceKey(ev);// w ww . j av a2 s . c om LinkedList<Long> q = trcMap.get(key); Long start = q.getLast(); if (start != null) { Long cur = timeMap.get(key + "-trace-time"); if (cur == null) cur = 0L; timeMap.put(key + "-trace-time", (cur + (time - start))); } /* this._trace("#TRACEEND# ", ev); long time = System.currentTimeMillis(); Long start = trcMap.remove(ev.m_sourceNode); if (start != null) { Long cur = timeMap.get("trace-time"); if (cur == null) cur = 0L; timeMap.put("trace-time", (cur + (time - start))); } if (ev != null && ev.m_sourceNode != null) { log.info("traceEnd " + ev.m_sourceNode.getLocalName()); } */ }
From source file:org.opendaylight.topoprocessing.utils.SuurballeAlgorithm.java
/** * @param path Path//ww w . j av a 2 s. c o m * @param target Target vertex * @param union Union of paths * @return */ private List<E> mergePaths(List<E> path, V target, List<E> union) { LinkedList<E> mergedPath = new LinkedList<E>(); mergedPath.add(path.get(0)); union.remove(path.get(0)); V curDest; while (!(curDest = graph.getDest(mergedPath.getLast())).equals(target)) { boolean progress = false; for (E edge : union) { if (graph.isSource(curDest, edge)) { mergedPath.add(edge); progress = true; union.remove(edge); break; } } if (!progress) { return null; } if (union.isEmpty()) { if (!graph.isDest(target, mergedPath.getLast())) throw new RuntimeException("Bad"); else break; } } return mergedPath; }
From source file:org.movsim.simulator.roadnetwork.RoadSegment.java
private static double travelTimeInRange(double begin, double end, double maxRoadSpeed, LinkedList<Vehicle> vehicles) { int count = 0; double sumSpeed = 0; while (!vehicles.isEmpty() && vehicles.getLast().getFrontPosition() < end) { Vehicle veh = vehicles.removeLast(); sumSpeed += Math.max(veh.getSpeed(), MIN_SPEED_TT); count++;// w w w . j a va2 s . c o m } double avgSpeed = (count == 0) ? maxRoadSpeed : sumSpeed / count; return (end - begin) / avgSpeed; }
From source file:com.kixeye.chassis.support.metrics.aws.MetricsCloudWatchReporter.java
private void addDatum(String name, double value, LinkedList<PutMetricDataRequest> requests, Date timestamp) { if (logger.isDebugEnabled()) { logger.debug("Adding Datum {} with value {} at {}", name, value, timestamp); }/* w ww . j a v a 2 s .c o m*/ if (requests.isEmpty() || requests.getLast().getMetricData().size() == MAX_CLOUDWATCH_DATUM_PER_REQUEST) { requests.add(createRequest()); } PutMetricDataRequest request = requests.getLast(); MetricDatum datum = new MetricDatum().withTimestamp(timestamp).withValue(value).withMetricName(name) .withUnit(StandardUnit.None).withDimensions(createDimensions()); request.withMetricData(datum); }
From source file:com.splicemachine.derby.stream.function.merge.AbstractMergeJoinFlatMapFunction.java
protected void initRightScan(PeekingIterator<LocatedRow> leftPeekingIterator) throws StandardException { ExecRow firstHashRow = joinOperation.getKeyRow(leftPeekingIterator.peek().getRow()); ExecRow startPosition = joinOperation.getRightResultSet().getStartPosition(); int[] columnOrdering = getColumnOrdering(joinOperation.getRightResultSet()); int nCols = startPosition != null ? startPosition.nColumns() : 0; ExecRow scanStartOverride = null;/*from w w w .ja v a 2 s. c o m*/ int[] scanKeys = null; // If start row of right table scan has as many columns as key colummns of the table, cannot further // narrow down scan space, so return right tabel scan start row. if (nCols == columnOrdering.length) { scanStartOverride = startPosition; scanKeys = columnOrdering; } else { int[] rightHashKeys = joinOperation.getRightHashKeys(); // Find valid hash column values to narrow down right scan. The valid hash columns must: // 1) not be used as a start key for inner table scan // 2) be consecutive // 3) be a key column LinkedList<Pair<Integer, Integer>> hashColumnIndexList = new LinkedList<>(); for (int i = 0; i < rightHashKeys.length; ++i) { if (rightHashKeys[i] > nCols - 1) { if ((hashColumnIndexList.isEmpty() || hashColumnIndexList.getLast().getValue() == rightHashKeys[i] - 1) && isKeyColumn(columnOrdering, rightHashKeys[i])) { hashColumnIndexList.add(new ImmutablePair<Integer, Integer>(i, rightHashKeys[i])); } else { break; } } } scanStartOverride = new ValueRow(nCols + hashColumnIndexList.size()); if (startPosition != null) { for (int i = 1; i <= startPosition.nColumns(); ++i) { scanStartOverride.setColumn(i, startPosition.getColumn(i)); } } for (int i = 0; i < hashColumnIndexList.size(); ++i) { Pair<Integer, Integer> hashColumnIndex = hashColumnIndexList.get(i); int index = hashColumnIndex.getKey(); scanStartOverride.setColumn(nCols + i + 1, firstHashRow.getColumn(index + 1)); } // Scan key should include columns // 1) preceding the first hash column, these columns are in the form of "col=constant" // 2) all hash columns that are key columns scanKeys = new int[hashColumnIndexList.size() + rightHashKeys[0]]; for (int i = 0; i < rightHashKeys[0]; ++i) { scanKeys[i] = i; } for (int i = 0; i < hashColumnIndexList.size(); ++i) { Pair<Integer, Integer> hashColumnIndex = hashColumnIndexList.get(i); int colPos = hashColumnIndex.getValue(); scanKeys[rightHashKeys[0] + i] = colPos; } } ((BaseActivation) joinOperation.getActivation()).setScanStartOverride(scanStartOverride); ((BaseActivation) joinOperation.getActivation()).setScanKeys(scanKeys); if (startPosition != null) { ((BaseActivation) joinOperation.getActivation()).setScanStopOverride(startPosition); } }