List of usage examples for java.lang Long longValue
@HotSpotIntrinsicCandidate public long longValue()
From source file:com.newatlanta.appengine.vfs.provider.GaeFileObject.java
/** * Returns the last modified time of this file. */// w w w . j a v a 2s . c o m @Override protected long doGetLastModifiedTime() { Long lastModified = (Long) metadata.getProperty(LAST_MODIFIED); return (lastModified != null ? lastModified.longValue() : 0); }
From source file:com.newatlanta.appengine.vfs.provider.GaeFileObject.java
/** * Returns the size of the file content (in bytes). *//*from w ww . ja va 2 s. c o m*/ @Override public long doGetContentSize() throws FileSystemException { if (exists() && !getType().hasContent()) { throw new FileSystemException("vfs.provider/get-size-not-file.error", getName()); } Long contentSize = (Long) metadata.getProperty(CONTENT_SIZE); return (contentSize != null ? contentSize.longValue() : 0); }
From source file:com.linkedin.pinot.query.aggregation.StarTreeQueriesTest.java
@Test(dataProvider = "groupByDataProvider") public void testGroupByQuery(Map<String, String> filterQuery, List<String> groupByDimensions) throws Exception { // Build request final BrokerRequest brokerRequest = new BrokerRequest(); final List<AggregationInfo> aggregationsInfo = new ArrayList<AggregationInfo>(); aggregationsInfo.add(getSumAggregationInfo()); brokerRequest.setAggregationsInfo(aggregationsInfo); if (!filterQuery.isEmpty()) { String[] flattened = flattenFilterQuery(filterQuery); setFilterQuery(brokerRequest, flattened[0], flattened[1]); }//from w w w . ja v a2 s . co m GroupBy groupBy = new GroupBy(); groupBy.setColumns(groupByDimensions); groupBy.setTopN(1000); // n.b. should be higher than any cardinality for test purposes brokerRequest.setGroupBy(groupBy); // Compute plan final PlanMaker instancePlanMaker = new InstancePlanMakerImplV3(); final PlanNode rootPlanNode = instancePlanMaker.makeInnerSegmentPlan(indexSegment, brokerRequest); rootPlanNode.showTree(""); Assert.assertEquals(rootPlanNode.getClass(), StarTreeAggregationGroupByOperatorPlanNode.class); // Perform aggregation final MAggregationGroupByOperator operator = (MAggregationGroupByOperator) rootPlanNode.run(); final IntermediateResultsBlock resultBlock = (IntermediateResultsBlock) operator.nextBlock(); // Get response final AggregationGroupByOperatorService aggregationGroupByOperatorService = new AggregationGroupByOperatorService( aggregationsInfo, brokerRequest.getGroupBy()); final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>(); instanceResponseMap.put(new ServerInstance("localhost:0000"), resultBlock.getAggregationGroupByResultDataTable()); instanceResponseMap.put(new ServerInstance("localhost:1111"), resultBlock.getAggregationGroupByResultDataTable()); instanceResponseMap.put(new ServerInstance("localhost:2222"), resultBlock.getAggregationGroupByResultDataTable()); instanceResponseMap.put(new ServerInstance("localhost:3333"), resultBlock.getAggregationGroupByResultDataTable()); instanceResponseMap.put(new ServerInstance("localhost:4444"), resultBlock.getAggregationGroupByResultDataTable()); instanceResponseMap.put(new ServerInstance("localhost:5555"), resultBlock.getAggregationGroupByResultDataTable()); instanceResponseMap.put(new ServerInstance("localhost:6666"), resultBlock.getAggregationGroupByResultDataTable()); instanceResponseMap.put(new ServerInstance("localhost:7777"), resultBlock.getAggregationGroupByResultDataTable()); instanceResponseMap.put(new ServerInstance("localhost:8888"), resultBlock.getAggregationGroupByResultDataTable()); instanceResponseMap.put(new ServerInstance("localhost:9999"), resultBlock.getAggregationGroupByResultDataTable()); final List<Map<String, Serializable>> reducedResults = aggregationGroupByOperatorService .reduceGroupByOperators(instanceResponseMap); // Check (we sent 10 broker requests, so assume 10x) final List<JSONObject> jsonResult = aggregationGroupByOperatorService .renderGroupByOperators(reducedResults); // Extract the group by sums Map<List<String>, Long> groupBySums = new HashMap<>(); JSONArray groupByResult = jsonResult.get(0).getJSONArray("groupByResult"); for (int i = 0; i < groupByResult.length(); i++) { // Get the group list List<String> group = new ArrayList<>(); JSONArray groupArray = groupByResult.getJSONObject(i).getJSONArray("group"); for (int j = 0; j < groupArray.length(); j++) { group.add(groupArray.getString(j)); } groupBySums.put(group, groupByResult.getJSONObject(i).getLong("value")); } // Get them from raw data Map<List<String>, Long> fromAvro = computeAggregateGroupByFromRawData(avroFile, filterQuery, groupByDimensions); // Compare Assert.assertEquals(groupBySums.size(), fromAvro.size()); for (List<String> group : fromAvro.keySet()) { Long m0Avro = fromAvro.get(group); Long m0Pinot = groupBySums.get(group); Assert.assertEquals(m0Pinot.longValue(), m0Avro * 10 /* because broker queries */); } }
From source file:jp.primecloud.auto.puppet.PuppetClient.java
public void runClient(String fqdn) { // siteFile?touch? touchFile(siteFile);//from ww w . j a v a 2s .c o m // ??touch? File manifestFile = new File(manifestDir, fqdn + ".pp"); touchFile(manifestFile.getAbsolutePath()); // ??? if (delayTime != null) { try { Thread.sleep(delayTime.intValue() * 1000); } catch (InterruptedException ignore) { } } // puppetrun????? String beforeReportFile = reportLoader.getLatestReportFile(fqdn); Long beforeLastModified = null; if (beforeReportFile != null) { beforeLastModified = reportLoader.getLastModified(fqdn, beforeReportFile); } List<String> commands = new ArrayList<String>(); commands.add("/usr/bin/sudo"); commands.add(puppetrunPath); commands.add("--host"); commands.add(fqdn); commands.add("--foreground"); // Puppet??? commands.add("--ping"); // puppetrun?? if (configTimeout != null) { commands.add("--configtimeout=" + configTimeout.toString()); } log.debug(commands); CommandResult result = executeRun(commands); int retryCount = 0; while (result.getExitValue() != 0 && retryCount < 6) { // ??????? boolean retry = false; for (String stdout : result.getStdouts()) { log.warn(stdout); if (stdout.contains("Certificates were not trusted: ")) { retry = true; break; } else if (stdout.contains("Connection reset by peer")) { retry = true; break; } else if (stdout.contains("Could not contact")) { retry = true; break; } } if (!retry) { // ???? break; } // ??? log.warn(ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE)); // ?? try { Thread.sleep(5 * 1000); } catch (InterruptedException ignore) { } result = executeRun(commands); retryCount++; } if (result.getExitValue() != 0) { // puppetrun?? AutoException exception; if (result.getStdouts().size() > 0 && result.getStdouts().get(0).contains("Could not contact")) { // ??ping???????? exception = new AutoException("EPUPPET-000002", fqdn); } else if (result.getStdouts().size() > 0 && result.getStdouts().get(0).contains("Could not connect")) { // ??????????????? try { Thread.sleep(100000); } catch (InterruptedException ignore) { } //? exception = new AutoException("EPUPPET-000007", fqdn); } else if (result.getStdouts().size() > 0 && result.getStdouts().get(0).contains("returned unknown answer")) { // ???????????????() try { Thread.sleep(100000); } catch (InterruptedException ignore) { } //? exception = new AutoException("EPUPPET-000007", fqdn); } else { exception = new AutoException("EPUPPET-000001", fqdn); } exception.addDetailInfo( "result=" + ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE)); throw exception; } // ??? String reportFile = null; for (int i = 0; i < 30; i++) { try { Thread.sleep(1 * 1000); } catch (InterruptedException ignore) { } String tmpReportFile = reportLoader.getLatestReportFile(fqdn); if (tmpReportFile != null) { if (beforeLastModified == null) { reportFile = tmpReportFile; break; } else { Long lastModified = reportLoader.getLastModified(fqdn, tmpReportFile); if (lastModified.longValue() != beforeLastModified.longValue()) { reportFile = tmpReportFile; break; } } } } if (reportFile != null) { // ????? Map<String, Object> report = reportLoader.loadReport(fqdn, reportFile); String status = reportAnalyzer.getStatus(report); if (status.equals("failed")) { // ????????() throw new AutoException("EPUPPET-000003", fqdn, reportFile); } List<MetricsResource> metricsResources = reportAnalyzer.getMetricsResources(report); for (MetricsResource metricsResource : metricsResources) { if (metricsResource.getName().startsWith("Failed") && metricsResource.getCount() > 0) { // ???????? throw new AutoException("EPUPPET-000003", fqdn, reportFile); } } } else { // ???????? throw new AutoException("EPUPPET-000007", fqdn); } }
From source file:com.github.gerbsen.math.Frequency.java
/** * Returns the cumulative frequency of values less than or equal to v. * <p>// ww w. j av a 2 s. co m * Returns 0 if v is not comparable to the values set.</p> * * @param v the value to lookup. * @return the proportion of values equal to v */ public long getCumFreq(Comparable<?> v) { if (getSumFreq() == 0) { return 0; } if (v instanceof Integer) { return getCumFreq(((Integer) v).longValue()); } @SuppressWarnings("unchecked") // OK, freqTable is Comparable<?> Comparator<Comparable<?>> c = (Comparator<Comparable<?>>) freqTable.comparator(); if (c == null) { c = new NaturalComparator(); } long result = 0; try { Long value = freqTable.get(v); if (value != null) { result = value.longValue(); } } catch (ClassCastException ex) { return result; // v is not comparable } if (c.compare(v, freqTable.firstKey()) < 0) { return 0; // v is comparable, but less than first value } if (c.compare(v, freqTable.lastKey()) >= 0) { return getSumFreq(); // v is comparable, but greater than the last value } Iterator<Comparable<?>> values = valuesIterator(); while (values.hasNext()) { Comparable<?> nextValue = values.next(); if (c.compare(v, nextValue) > 0) { result += getCount(nextValue); } else { return result; } } return result; }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.ConceptNameControllerTest.java
@Test public void shouldPurgeAConceptName() throws Exception { String conceptId = "5497"; //using sql to be able to include voided names too Long before = (Long) Context.getAdministrationService() .executeSQL("select count(*) from concept_name where concept_id = " + conceptId, true).get(0) .get(0);// w ww .jav a2 s .c om controller.purge(conceptUuid2, "8230adbf-30a9-4e18-b6d7-fc57e0c23cab", request, response); Long after = (Long) Context.getAdministrationService() .executeSQL("select count(*) from concept_name where concept_id = " + conceptId, true).get(0) .get(0); Assert.assertEquals(before.longValue() - 1, after.longValue()); }
From source file:cherry.spring.common.foundation.impl.AsyncProcessStoreImpl.java
private long createAsyncProcess(final String launcherId, final String description, final AsyncType asyncType, final LocalDateTime dtm) { final QAsyncProcess a = new QAsyncProcess("a"); SqlInsertWithKeyCallback<Long> callback = new SqlInsertWithKeyCallback<Long>() { @Override/*from w w w . ja v a2 s.c om*/ public Long doInSqlInsertWithKeyClause(SQLInsertClause insert) { insert.set(a.launchedBy, launcherId); insert.set(a.description, adjustSize(description, a.description)); insert.set(a.asyncType, asyncType.code()); insert.set(a.asyncStatus, AsyncStatus.LAUNCHING.code()); insert.set(a.registeredAt, dtm); return insert.executeWithKey(Long.class); } }; Long id = queryDslJdbcOperations.insertWithKey(a, callback); checkState(id != null, "failed to create QAsyncProcess: launchedBy={0}, description={1}, asyncType={2}, asyncStatus={3}, registeredAt={4}", launcherId, description, asyncType.code(), AsyncStatus.LAUNCHING.code(), dtm); return id.longValue(); }
From source file:com.github.dozermapper.core.functional_tests.MapperTest.java
@Test public void testLongToLongMapping() { // Map//from w ww.j av a 2s . c o m TestObject source = testDataFactory.getInputGeneralMappingTestObject(); source.setAnotherLongValue(42); TestObjectPrime prime2 = mapper.map(source, TestObjectPrime.class); Long value = prime2.getTheLongValue(); assertEquals(value.longValue(), 42); }
From source file:org.alfresco.encryption.DefaultEncryptionUtils.java
/** * {@inheritDoc}// w ww.ja va 2 s.c o m */ @Override public boolean authenticateResponse(HttpMethod method, String remoteIP, byte[] decryptedBody) { try { byte[] expectedMAC = getResponseMac(method); Long timestamp = getResponseTimestamp(method); if (timestamp == null) { return false; } remoteIP = IPUtils.getRealIPAddress(remoteIP); return authenticate(expectedMAC, new MACInput(decryptedBody, timestamp.longValue(), remoteIP)); } catch (Exception e) { throw new RuntimeException("Unable to authenticate HTTP response", e); } }
From source file:org.alfresco.encryption.DefaultEncryptionUtils.java
/** * {@inheritDoc}//from w w w . ja v a2 s .com */ @Override public boolean authenticate(HttpServletRequest req, byte[] decryptedBody) { try { byte[] expectedMAC = getMac(req); Long timestamp = getTimestamp(req); if (timestamp == null) { return false; } String ipAddress = IPUtils.getRealIPAddress(req.getRemoteAddr()); return authenticate(expectedMAC, new MACInput(decryptedBody, timestamp.longValue(), ipAddress)); } catch (Exception e) { throw new AlfrescoRuntimeException("Unable to authenticate HTTP request", e); } }