List of usage examples for java.lang Long longValue
@HotSpotIntrinsicCandidate public long longValue()
From source file:com.googlecode.icegem.cacheutils.comparator.CompareTool.java
@SuppressWarnings("unchecked") private ComparisonResult calculateResult(long[] ids) throws IOException, InterruptedException, ClassNotFoundException { ComparisonResult result = new ComparisonResult(); Process sourceProcess;//from w w w . j a va 2s. co m Process targetProcess; if (isPartitioned()) { sourceProcess = runProcess(PARTITION, sourceLocators, sourceRegionName, SOURCE_INPUT_FILENAME, SOURCE_OUTPUT_FILENAME, ids, 16); targetProcess = runProcess(PARTITION, targetLocators, targetRegionName, TARGET_INPUT_FILENAME, TARGET_OUTPUT_FILENAME, ids, 16); } else { sourceProcess = runProcess(REPLICATE, sourceServer, sourceRegionName, SOURCE_INPUT_FILENAME, SOURCE_OUTPUT_FILENAME, ids, 16); targetProcess = runProcess(REPLICATE, targetServer, targetRegionName, TARGET_INPUT_FILENAME, TARGET_OUTPUT_FILENAME, ids, 16); } sourceProcess.waitFor(); targetProcess.waitFor(); Set<Node> sourceNodesSet = (Set<Node>) FileService.readObject(SOURCE_OUTPUT_FILENAME); Set<Node> targetNodesSet = (Set<Node>) FileService.readObject(TARGET_OUTPUT_FILENAME); Map<Object, Long> sourceDataToHashcodeMap = new HashMap<Object, Long>(); Map<Object, Long> targetDataToHashcodeMap = new HashMap<Object, Long>(); for (Node node : sourceNodesSet) { for (Node child : node.getChildren()) { sourceDataToHashcodeMap.put(child.getData(), child.getHashcode()); } } for (Node node : targetNodesSet) { for (Node child : node.getChildren()) { targetDataToHashcodeMap.put(child.getData(), child.getHashcode()); } } Set<Object> dataSet = new HashSet<Object>(); dataSet.addAll(sourceDataToHashcodeMap.keySet()); dataSet.addAll(targetDataToHashcodeMap.keySet()); for (Object data : dataSet) { Long sourceHashcode = sourceDataToHashcodeMap.get(data); Long targetHashcode = targetDataToHashcodeMap.get(data); if (sourceHashcode == null) { result.addMissed(data); } else if (targetHashcode == null) { result.addExtra(data); } else if (sourceHashcode.longValue() != targetHashcode.longValue()) { result.addDifferent(data); } else { throw new IllegalStateException( "The entry with key = " + data + " neither extra, missed nor different"); } } return result; }
From source file:org.apache.streams.twitter.provider.TwitterFriendsProviderTask.java
protected void getFriends(Long id) { int keepTrying = 0; long curser = -1; do {/*from w w w . j av a 2 s . co m*/ try { twitter4j.User follower4j; String followerJson; try { follower4j = client.users().showUser(id); followerJson = TwitterObjectFactory.getRawJSON(follower4j); } catch (TwitterException e) { LOGGER.error("Failure looking up " + id); break; } PagableResponseList<User> followeeList = client.friendsFollowers().getFriendsList(id.longValue(), curser); for (twitter4j.User followee4j : followeeList) { String followeeJson = TwitterObjectFactory.getRawJSON(followee4j); try { Follow follow = new Follow() .withFollowee( mapper.readValue(followeeJson, org.apache.streams.twitter.pojo.User.class)) .withFollower( mapper.readValue(followerJson, org.apache.streams.twitter.pojo.User.class)); ComponentUtils.offerUntilSuccess(new StreamsDatum(follow), provider.providerQueue); } catch (JsonParseException e) { LOGGER.warn(e.getMessage()); } catch (JsonMappingException e) { LOGGER.warn(e.getMessage()); } catch (IOException e) { LOGGER.warn(e.getMessage()); } } curser = followeeList.getNextCursor(); } catch (TwitterException twitterException) { keepTrying += TwitterErrorHandler.handleTwitterError(client, twitterException); } catch (Exception e) { keepTrying += TwitterErrorHandler.handleTwitterError(client, e); } } while (curser != 0 && keepTrying < 10); }
From source file:com.germinus.easyconf.ComponentProperties.java
public long getLong(String key, Filter filter) { Long value = getLong(key, filter, null); validateValue(key, value);//from w w w. j ava2s. c om return value.longValue(); }
From source file:edu.utah.further.fqe.impl.service.query.AggregationServiceImpl.java
/** * Scrub positive counts that are smaller than the mask boundary value. By convention, * all scrubbed entries are set to {@link Constants#INVALID_VALUE_BOXED_LONG}. * /*from ww w.j a v a 2 s . c o m*/ * @param results * raw counts * @return scrubbed results */ @Override public AggregatedResults scrubResults(final AggregatedResults results) { for (final AggregatedResult result : results.getResults()) { for (final Category category : result.getCategories()) { // FUR-1745: (a) find all categories with small entries final Set<String> smallEntryKeys = CollectionUtil.newSet(); for (final Map.Entry<String, Long> entry : category.getEntries().entrySet()) { final Long value = entry.getValue(); if (FqeQueryContextUtil.shouldBeMasked(value.longValue(), resultMaskBoundary)) { smallEntryKeys.add(entry.getKey()); // category.addEntry(entry.getKey(), // Constants.INVALID_VALUE_BOXED_LONG); } } // FUR-1745: (b) lump all small entries into one "Other" category if (!smallEntryKeys.isEmpty()) { for (final String key : smallEntryKeys) { category.removeEntry(key); } category.addEntry(resultMaskOther, Constants.INVALID_VALUE_BOXED_LONG); } if (category.getName().equals("Age")) { if (category.removeEntry(Strings.NULL_TO_STRING) != null) { category.addEntry(resultMaskOther, Constants.INVALID_VALUE_BOXED_LONG); } } } } return results; }
From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java
License:asdf
@Test public void putValueLong() { ObjectNode parent = new ObjectNode(factory); String name = "foo"; Long value = 1272722l;// w w w.java 2 s . com parser.putValue(parent, name, value); JsonNode x = parent.get(name); Assert.assertNotNull(x); Assert.assertEquals(value.longValue(), x.longValue()); }
From source file:etymology.config.Configuration.java
public void setRandomSeed(Long randomSeed) { if (randomSeed == null) { this.randomSeed = new Random().nextInt(); } else {/*from ww w .jav a 2 s. c o m*/ this.randomSeed = randomSeed.longValue(); } this.random = new Random(this.randomSeed); randomSeedIsSet = true; }
From source file:gov.nih.nci.ncicb.tcga.dcc.common.dao.UUIDDAOImpl.java
@Override public void addParticipantFileUUIDAssociation(final String UUID, final Long fileId) { if (StringUtils.isNotEmpty(UUID) && fileId != null && fileId.longValue() > 0) { Object[] patientUUIDArray = { UUID.toLowerCase(), fileId, UUID.toLowerCase(), fileId }; List patientUUIDArrayList = new ArrayList<Object[]>(); patientUUIDArrayList.add(patientUUIDArray); addParticipantFileUUIDAssociation(patientUUIDArrayList); } else {/*from w ww . java 2 s .c o m*/ if (StringUtils.isEmpty(UUID)) { throw new IllegalArgumentException(" Non empty UUID must be present"); } if (fileId == null || fileId.longValue() <= 0) { throw new IllegalArgumentException(" Non empty file Id must be present"); } } }
From source file:com.alibaba.jstorm.schedule.FollowerRunnable.java
private synchronized void check() { StormClusterState clusterState = data.getStormClusterState(); try {/*from ww w .j a v a 2 s. c o m*/ String master_stormdist_root = StormConfig.masterStormdistRoot(data.getConf()); List<String> code_ids = PathUtils.read_dir_contents(master_stormdist_root); List<String> assignments_ids = clusterState.assignments(callback); Map<String, Assignment> assignmentMap = new HashMap<String, Assignment>(); List<String> update_ids = new ArrayList<String>(); for (String id : assignments_ids) { Assignment assignment = clusterState.assignment_info(id, null); Long localCodeDownTS; try { Long tmp = StormConfig.read_nimbus_topology_timestamp(data.getConf(), id); localCodeDownTS = (tmp == null ? 0L : tmp); } catch (FileNotFoundException e) { localCodeDownTS = 0L; } if (assignment != null && assignment.isTopologyChange(localCodeDownTS.longValue())) { update_ids.add(id); } assignmentMap.put(id, assignment); } List<String> done_ids = new ArrayList<String>(); for (String id : code_ids) { if (assignments_ids.contains(id)) { done_ids.add(id); } } for (String id : done_ids) { assignments_ids.remove(id); code_ids.remove(id); } //redownload topologyid which hava been updated; assignments_ids.addAll(update_ids); for (String topologyId : code_ids) { deleteLocalTopology(topologyId); } for (String id : assignments_ids) { downloadCodeFromMaster(assignmentMap.get(id), id); } } catch (IOException e) { // TODO Auto-generated catch block LOG.error("Get stormdist dir error!", e); return; } catch (Exception e) { // TODO Auto-generated catch block LOG.error("Check error!", e); return; } }
From source file:com.gsma.mobileconnect.impl.DiscoveryImplTest.java
@Test public void determineTtl_withValidValue_shouldReturnValueUnchanged() { // GIVEN/*from w ww.ja v a 2s . com*/ Long ttlValue = new Date().getTime() + MIN_TTL_VALUE + 1000; DiscoveryImpl discovery = new DiscoveryImpl(null, null); // WHEN Date ttl = discovery.determineTtl(ttlValue); // THEN assertEquals(ttlValue.longValue(), ttl.getTime()); }
From source file:com.brightcove.com.zartan.verifier.ExistenceVerifier.java
/** * Asserts that a video is retrievable via Media api. * This wraps JUnit asserts and will behave accordingly. * @param videoID video to find//from ww w. java 2 s .c om * @param token api read token the video belongs to * @throws MediaAPIError * @throws URISyntaxException * @throws JSONException */ public void assertVideoExists(Long videoID, String token) throws MediaAPIError, URISyntaxException, JSONException { List<NameValuePair> parameters = new ArrayList<NameValuePair>(); parameters.add(new BasicNameValuePair("command", "find_video_by_id")); parameters.add(new BasicNameValuePair("video_id", "" + videoID)); parameters.add(new BasicNameValuePair("token", token)); // Build up URL from the parameters provided JsonNode jsonObject = mMediaAPIHelper.executeRead(mEnvironment, parameters); mLog.info("response to find by ID (" + videoID + "): " + jsonObject); assertNotNull(jsonObject); assertNotNull(jsonObject.get("id")); assertEquals(videoID.longValue(), jsonObject.get("id").getLongValue()); }