List of usage examples for java.lang Float POSITIVE_INFINITY
float POSITIVE_INFINITY
To view the source code for java.lang Float POSITIVE_INFINITY.
Click Source Link
From source file:net.sf.javaml.clustering.AQBC.java
/** * implements clusterdistrib/*from w w w. j a va2 s . c om*/ * * @param r * @param VAR * @param D * @param R * @return */ private double[] clusterdistrib(double[] r, double VAR, double D, double R) { // System.out.println("\t\tCD:VAR = "+VAR); // System.out.println("\t\tCD:D = "+D); // System.out.println("\t\tCD:R = "+R); // System.out.println("\t\tCD:r = "+Arrays.toString(r)); double[] out = new double[r.length]; if (MathUtils.eq(VAR, 0)) { // System.out.println("\t\tCD: VAR is considered ZERO !!!"); for (int i = 0; i < r.length; i++) { if (MathUtils.eq(r[i], 0)) { out[i] = Float.POSITIVE_INFINITY; } } } else { double SD = (2 * Math.pow(Math.PI, D / 2)) / (GammaFunction.gamma(D / 2)); double tmp_piVAR = 2 * Math.PI * VAR; double tmp_piVARpow = Math.pow(tmp_piVAR, D / 2); double tmp_piVARpowINV = 1 / tmp_piVARpow; // System.out.println("\t\tCD:SD = "+SD); // System.out.println("\t\tCD:tmp_piVAR = "+tmp_piVAR); // System.out.println("\t\tCD:tmp_piVARpow = "+tmp_piVARpow); // System.out.println("\t\tCD:tmp_piVARpowINV = "+tmp_piVARpowINV); for (int i = 0; i < r.length; i++) { double tmp_exp = -((r[i] * r[i]) / (2 * VAR)); // System.out.println("\t\tMath.pow(r[i],D-1) = // "+Math.pow(r[i],D-1)); // System.out.println("\t\tCD:tmp_exp = "+tmp_exp); // System.out.println("\t\tCD:exp(tmp_exp) = // "+Math.exp(tmp_exp)); out[i] = (float) (SD * tmp_piVARpowINV * Math.pow(r[i], D - 1) * Math.exp(tmp_exp)); } for (int i = 0; i < r.length; i++) { if (MathUtils.eq(r[i], 0)) out[i] = 1; } } return out; }
From source file:byps.test.TestSerializePrimitiveTypes.java
@Test public void testSerializeFloat() throws BException { log.info("testSerializeFloat("); internalTestSerializeFloat(Float.NaN); internalTestSerializeFloat(Float.NEGATIVE_INFINITY); internalTestSerializeFloat(Float.POSITIVE_INFINITY); internalTestSerializeFloat(0.0f);//from w w w.j a v a 2 s. com internalTestSerializeFloat(1.0f); internalTestSerializeFloat(-1.0f); internalTestSerializeFloat(1.0e7f); internalTestSerializeFloat(1.0e-7f); internalTestSerializeFloat(2.0E5f); log.info(")testSerializeFloat"); }
From source file:edu.harvard.iq.dataverse.dataaccess.TabularSubsetGenerator.java
public static Float[] subsetFloatVector(InputStream in, int column, int numCases) { Float[] retVector = new Float[numCases]; Scanner scanner = new Scanner(in); scanner.useDelimiter("\\n"); for (int caseIndex = 0; caseIndex < numCases; caseIndex++) { if (scanner.hasNext()) { String[] line = (scanner.next()).split("\t", -1); // Verified: new Float("nan") works correctly, // resulting in Float.NaN; // Float("[+-]Inf") doesn't work however; // (the constructor appears to be expecting it // to be spelled as "Infinity", "-Infinity", etc. if ("inf".equalsIgnoreCase(line[column]) || "+inf".equalsIgnoreCase(line[column])) { retVector[caseIndex] = java.lang.Float.POSITIVE_INFINITY; } else if ("-inf".equalsIgnoreCase(line[column])) { retVector[caseIndex] = java.lang.Float.NEGATIVE_INFINITY; } else if (line[column] == null || line[column].equals("")) { // missing value: retVector[caseIndex] = null; } else { try { retVector[caseIndex] = new Float(line[column]); } catch (NumberFormatException ex) { retVector[caseIndex] = null; // missing value }/* w w w .j a v a 2 s .c om*/ } } else { scanner.close(); throw new RuntimeException("Tab file has fewer rows than the stored number of cases!"); } } int tailIndex = numCases; while (scanner.hasNext()) { String nextLine = scanner.next(); if (!"".equals(nextLine)) { scanner.close(); throw new RuntimeException( "Column " + column + ": tab file has more nonempty rows than the stored number of cases (" + numCases + ")! current index: " + tailIndex + ", line: " + nextLine); } tailIndex++; } scanner.close(); return retVector; }
From source file:gov.nih.nci.caarray.util.CaArrayUtils.java
private static float xmlStringToFloat(String value) { if ("NaN".equals(value)) { return Float.NaN; } else if ("INF".equals(value)) { return Float.POSITIVE_INFINITY; } else if ("-INF".equals(value)) { return Float.NEGATIVE_INFINITY; } else {// w w w . java 2 s. c om return Float.parseFloat(value); } }
From source file:org.shaman.terrain.polygonal.PolygonalMapGenerator.java
/** * Step 4: assign elevation//from ww w . j a v a 2 s . c o m */ private void assignElevation() { if (graph == null) { return; } Random rand = new Random(seed * 2); //initialize border corners with zero elevation Deque<Graph.Corner> q = new ArrayDeque<>(); for (Graph.Corner c : graph.corners) { if (c.border) { c.elevation = 0; q.add(c); } else { c.elevation = Float.POSITIVE_INFINITY; } } // Traverse the graph and assign elevations to each point. As we // move away from the map border, increase the elevations. This // guarantees that rivers always have a way down to the coast by // going downhill (no local minima). while (!q.isEmpty()) { Graph.Corner c = q.poll(); for (Graph.Corner a : c.adjacent) { if (c.ocean && a.ocean && a.elevation > 0) { a.elevation = 0; q.addFirst(a); continue; } float elevation = c.elevation + (a.ocean ? 0 : 0.01f); if (!c.water && !a.water) { elevation += 1; } //add some more randomness //elevation += rand.nextDouble()/4; if (elevation < a.elevation) { a.elevation = elevation; q.add(a); } } } //redistribute elevation float SCALE_FACTOR = 1.1f; ArrayList<Graph.Corner> corners = new ArrayList<>(); for (Graph.Corner c : graph.corners) { if (!c.ocean) { corners.add(c); } } Collections.sort(corners, new Comparator<Graph.Corner>() { @Override public int compare(Graph.Corner o1, Graph.Corner o2) { return Float.compare(o1.elevation, o2.elevation); } }); for (int i = 0; i < corners.size(); i++) { // Let y(x) be the total area that we want at elevation <= x. // We want the higher elevations to occur less than lower // ones, and set the area to be y(x) = 1 - (1-x)^2. float y = (float) i / (float) (corners.size() - 1); float x = (float) (Math.sqrt(SCALE_FACTOR) - Math.sqrt(SCALE_FACTOR * (1 - y))); if (x > 1.0) x = 1; // TODO: does this break downslopes? corners.get(i).elevation = x; } assignCenterElevations(); //update mesh updateElevationGeometry(); }
From source file:com.xqdev.jam.MLJAM.java
private static void sendXQueryResponse(HttpServletResponse res, Object o) throws IOException { // Make sure to leave the status code alone. It defaults to 200, but sometimes // callers of this method will have set it to a custom code. res.setContentType("x-marklogic/xquery; charset=UTF-8"); //res.setContentType("text/plain"); Writer writer = res.getWriter(); // care to handle errors later? if (o == null) { writer.write("()"); }/* w w w .j a va2 s.c om*/ else if (o instanceof byte[]) { writer.write("binary {'"); writer.write(hexEncode((byte[]) o)); writer.write("'}"); } else if (o instanceof Object[]) { Object[] arr = (Object[]) o; writer.write("("); for (int i = 0; i < arr.length; i++) { sendXQueryResponse(res, arr[i]); if (i + 1 < arr.length) writer.write(", "); } writer.write(")"); } else if (o instanceof String) { writer.write("'"); writer.write(escapeSingleQuotes(o.toString())); writer.write("'"); } else if (o instanceof Integer) { writer.write("xs:int("); writer.write(o.toString()); writer.write(")"); } else if (o instanceof Long) { writer.write("xs:integer("); writer.write(o.toString()); writer.write(")"); } else if (o instanceof Float) { Float flt = (Float) o; writer.write("xs:float("); if (flt.equals(Float.POSITIVE_INFINITY)) { writer.write("'INF'"); } else if (flt.equals(Float.NEGATIVE_INFINITY)) { writer.write("'-INF'"); } else if (flt.equals(Float.NaN)) { writer.write("fn:number(())"); // poor man's way to write NaN } else { writer.write(o.toString()); } writer.write(")"); } else if (o instanceof Double) { Double dbl = (Double) o; writer.write("xs:double("); if (dbl.equals(Double.POSITIVE_INFINITY)) { writer.write("'INF'"); } else if (dbl.equals(Double.NEGATIVE_INFINITY)) { writer.write("'-INF'"); } else if (dbl.equals(Double.NaN)) { writer.write("fn:number(())"); // poor man's way to write NaN } else { writer.write(o.toString()); } writer.write(")"); } else if (o instanceof Boolean) { writer.write("xs:boolean('"); writer.write(o.toString()); writer.write("')"); } else if (o instanceof BigDecimal) { writer.write("xs:decimal("); writer.write(o.toString()); writer.write(")"); } else if (o instanceof Date) { // We want something like: 2006-04-30T01:28:30.499-07:00 // We format to get: 2006-04-30T01:28:30.499-0700 // Then we add in the colon writer.write("xs:dateTime('"); String d = dateFormat.format((Date) o); writer.write(d.substring(0, d.length() - 2)); writer.write(":"); writer.write(d.substring(d.length() - 2)); writer.write("')"); } else if (o instanceof XMLGregorianCalendar) { XMLGregorianCalendar greg = (XMLGregorianCalendar) o; QName type = greg.getXMLSchemaType(); if (type.equals(DatatypeConstants.DATETIME)) { writer.write("xs:dateTime('"); } else if (type.equals(DatatypeConstants.DATE)) { writer.write("xs:date('"); } else if (type.equals(DatatypeConstants.TIME)) { writer.write("xs:time('"); } else if (type.equals(DatatypeConstants.GYEARMONTH)) { writer.write("xs:gYearMonth('"); } else if (type.equals(DatatypeConstants.GMONTHDAY)) { writer.write("xs:gMonthDay('"); } else if (type.equals(DatatypeConstants.GYEAR)) { writer.write("xs:gYear('"); } else if (type.equals(DatatypeConstants.GMONTH)) { writer.write("xs:gMonth('"); } else if (type.equals(DatatypeConstants.GDAY)) { writer.write("xs:gDay('"); } writer.write(greg.toXMLFormat()); writer.write("')"); } else if (o instanceof Duration) { Duration dur = (Duration) o; /* // The following fails on Xerces QName type = dur.getXMLSchemaType(); if (type.equals(DatatypeConstants.DURATION)) { writer.write("xs:duration('"); } else if (type.equals(DatatypeConstants.DURATION_DAYTIME)) { writer.write("xdt:dayTimeDuration('"); } else if (type.equals(DatatypeConstants.DURATION_YEARMONTH)) { writer.write("xdt:yearMonthDuration('"); } */ // If no years or months, must be DURATION_DAYTIME if (dur.getYears() == 0 && dur.getMonths() == 0) { writer.write("xdt:dayTimeDuration('"); } // If has years or months but nothing else, must be DURATION_YEARMONTH else if (dur.getDays() == 0 && dur.getHours() == 0 && dur.getMinutes() == 0 && dur.getSeconds() == 0) { writer.write("xdt:yearMonthDuration('"); } else { writer.write("xs:duration('"); } writer.write(dur.toString()); writer.write("')"); } else if (o instanceof org.jdom.Element) { org.jdom.Element elt = (org.jdom.Element) o; writer.write("xdmp:unquote('"); // Because "<" in XQuery is the same as "<" I need to double escape any ampersands writer.write(new org.jdom.output.XMLOutputter().outputString(elt).replaceAll("&", "&") .replaceAll("'", "''")); writer.write("')/*"); // make sure to return the root elt } else if (o instanceof org.jdom.Document) { org.jdom.Document doc = (org.jdom.Document) o; writer.write("xdmp:unquote('"); writer.write(new org.jdom.output.XMLOutputter().outputString(doc).replaceAll("&", "&") .replaceAll("'", "''")); writer.write("')"); } else if (o instanceof org.jdom.Text) { org.jdom.Text text = (org.jdom.Text) o; writer.write("text {'"); writer.write(escapeSingleQuotes(text.getText())); writer.write("'}"); } else if (o instanceof org.jdom.Attribute) { // <fake xmlns:pref="http://uri.com" pref:attrname="attrvalue"/>/@*:attrname // <fake xmlns="http://uri.com" attrname="attrvalue"/>/@*:attrname org.jdom.Attribute attr = (org.jdom.Attribute) o; writer.write("<fake xmlns"); if ("".equals(attr.getNamespacePrefix())) { writer.write("=\""); } else { writer.write(":" + attr.getNamespacePrefix() + "=\""); } writer.write(attr.getNamespaceURI()); writer.write("\" "); writer.write(attr.getQualifiedName()); writer.write("=\""); writer.write(escapeSingleQuotes(attr.getValue())); writer.write("\"/>/@*:"); writer.write(attr.getName()); } else if (o instanceof org.jdom.Comment) { org.jdom.Comment com = (org.jdom.Comment) o; writer.write("comment {'"); writer.write(escapeSingleQuotes(com.getText())); writer.write("'}"); } else if (o instanceof org.jdom.ProcessingInstruction) { org.jdom.ProcessingInstruction pi = (org.jdom.ProcessingInstruction) o; writer.write("processing-instruction "); writer.write(pi.getTarget()); writer.write(" {'"); writer.write(escapeSingleQuotes(pi.getData())); writer.write("'}"); } else if (o instanceof QName) { QName q = (QName) o; writer.write("fn:expanded-QName('"); writer.write(escapeSingleQuotes(q.getNamespaceURI())); writer.write("','"); writer.write(q.getLocalPart()); writer.write("')"); } else { writer.write("error('XQuery tried to retrieve unsupported type: " + o.getClass().getName() + "')"); } writer.flush(); }
From source file:de.tlabs.ssr.g1.client.SourcesView.java
public void transformToFitScene() { float xScalingFactor = 0.0f; float yScalingFactor = 0.0f; float xDiff;//www . ja v a2 s .com float yDiff; float[][] sceneBounds; float minBounds[]; float maxBounds[]; // if size of this view not yet initialized, wait until it is initialized if (!viewSizeInitialized) { transformToFitSceneFlag = true; return; } // get scene bounds in screen coordinates recalculateViewportTransformation(); // just to be sure we are using the latest values sceneBounds = getSceneBounds(viewportTransformation); minBounds = sceneBounds[0]; maxBounds = sceneBounds[1]; // get max x and y distances in pixels xDiff = maxBounds[0] - minBounds[0]; yDiff = maxBounds[1] - minBounds[1]; // recalculate scaling if (xDiff > 0 || yDiff > 0) { // calculate best scaling in x and y direction if (xDiff > 0) { xScalingFactor = ((float) getWidth() - FIT_SCENE_PIXEL_BORDER_2) / xDiff; } else { xScalingFactor = Float.POSITIVE_INFINITY; } if (yDiff > 0) { yScalingFactor = ((float) getHeight() - FIT_SCENE_PIXEL_BORDER_2) / yDiff; } else { yScalingFactor = Float.POSITIVE_INFINITY; } // set best scaling float scalingFactor = Math.min(xScalingFactor, yScalingFactor); zoomView(scalingFactor); recalculateViewportTransformation(newViewportTransformation, currentCenterRotation, currentScaling * scalingFactor, currentTranslation); } else { newViewportTransformation.set(viewportTransformation); } // get scene bounds using new scaling sceneBounds = getSceneBounds(newViewportTransformation); minBounds = sceneBounds[0]; maxBounds = sceneBounds[1]; // get max x and y distances in pixels xDiff = maxBounds[0] - minBounds[0]; yDiff = maxBounds[1] - minBounds[1]; // calculate translation to center the scene float transX = -minBounds[0] + (getWidth() - xDiff) / 2; float transY = -minBounds[1] + (getHeight() - yDiff) / 2; if (currentOrientation == Configuration.ORIENTATION_PORTRAIT) { translateView(transX, transY); } else if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { translateView(transY, -transX); } }
From source file:org.apache.hadoop.yarn.server.resourcemanager.ApplicationMasterService.java
@Override public AllocateResponse allocate(AllocateRequest request) throws YarnException, IOException { AMRMTokenIdentifier amrmTokenIdentifier = YarnServerSecurityUtils.authorizeRequest(); ApplicationAttemptId appAttemptId = amrmTokenIdentifier.getApplicationAttemptId(); ApplicationId applicationId = appAttemptId.getApplicationId(); this.amLivelinessMonitor.receivedPing(appAttemptId); /* check if its in cache */ AllocateResponseLock lock = responseMap.get(appAttemptId); if (lock == null) { String message = "Application attempt " + appAttemptId + " doesn't exist in ApplicationMasterService cache."; LOG.error(message);/*from w w w . ja va2 s . co m*/ throw new ApplicationAttemptNotFoundException(message); } synchronized (lock) { AllocateResponse lastResponse = lock.getAllocateResponse(); if (!hasApplicationMasterRegistered(appAttemptId)) { String message = "AM is not registered for known application attempt: " + appAttemptId + " or RM had restarted after AM registered . AM should re-register."; LOG.info(message); RMAuditLogger.logFailure(this.rmContext.getRMApps().get(appAttemptId.getApplicationId()).getUser(), AuditConstants.AM_ALLOCATE, "", "ApplicationMasterService", message, applicationId, appAttemptId); throw new ApplicationMasterNotRegisteredException(message); } if ((request.getResponseId() + 1) == lastResponse.getResponseId()) { /* old heartbeat */ return lastResponse; } else if (request.getResponseId() + 1 < lastResponse.getResponseId()) { String message = "Invalid responseId in AllocateRequest from application attempt: " + appAttemptId + ", expect responseId to be " + (lastResponse.getResponseId() + 1); throw new InvalidApplicationMasterRequestException(message); } //filter illegal progress values float filteredProgress = request.getProgress(); if (Float.isNaN(filteredProgress) || filteredProgress == Float.NEGATIVE_INFINITY || filteredProgress < 0) { request.setProgress(0); } else if (filteredProgress > 1 || filteredProgress == Float.POSITIVE_INFINITY) { request.setProgress(1); } // Send the status update to the appAttempt. this.rmContext.getDispatcher().getEventHandler() .handle(new RMAppAttemptStatusupdateEvent(appAttemptId, request.getProgress())); List<ResourceRequest> ask = request.getAskList(); List<ContainerId> release = request.getReleaseList(); ResourceBlacklistRequest blacklistRequest = request.getResourceBlacklistRequest(); List<String> blacklistAdditions = (blacklistRequest != null) ? blacklistRequest.getBlacklistAdditions() : Collections.EMPTY_LIST; List<String> blacklistRemovals = (blacklistRequest != null) ? blacklistRequest.getBlacklistRemovals() : Collections.EMPTY_LIST; RMApp app = this.rmContext.getRMApps().get(applicationId); // set label expression for Resource Requests if resourceName=ANY ApplicationSubmissionContext asc = app.getApplicationSubmissionContext(); for (ResourceRequest req : ask) { if (null == req.getNodeLabelExpression() && ResourceRequest.ANY.equals(req.getResourceName())) { req.setNodeLabelExpression(asc.getNodeLabelExpression()); } } Resource maximumCapacity = rScheduler.getMaximumResourceCapability(); // sanity check try { RMServerUtils.normalizeAndValidateRequests(ask, maximumCapacity, app.getQueue(), rScheduler, rmContext); } catch (InvalidResourceRequestException e) { LOG.warn("Invalid resource ask by application " + appAttemptId, e); throw e; } try { RMServerUtils.validateBlacklistRequest(blacklistRequest); } catch (InvalidResourceBlacklistRequestException e) { LOG.warn("Invalid blacklist request by application " + appAttemptId, e); throw e; } // In the case of work-preserving AM restart, it's possible for the // AM to release containers from the earlier attempt. if (!app.getApplicationSubmissionContext().getKeepContainersAcrossApplicationAttempts()) { try { RMServerUtils.validateContainerReleaseRequest(release, appAttemptId); } catch (InvalidContainerReleaseException e) { LOG.warn("Invalid container release by application " + appAttemptId, e); throw e; } } // Split Update Resource Requests into increase and decrease. // No Exceptions are thrown here. All update errors are aggregated // and returned to the AM. List<UpdateContainerRequest> increaseResourceReqs = new ArrayList<>(); List<UpdateContainerRequest> decreaseResourceReqs = new ArrayList<>(); List<UpdateContainerError> updateContainerErrors = RMServerUtils.validateAndSplitUpdateResourceRequests( rmContext, request, maximumCapacity, increaseResourceReqs, decreaseResourceReqs); // Send new requests to appAttempt. Allocation allocation; RMAppAttemptState state = app.getRMAppAttempt(appAttemptId).getAppAttemptState(); if (state.equals(RMAppAttemptState.FINAL_SAVING) || state.equals(RMAppAttemptState.FINISHING) || app.isAppFinalStateStored()) { LOG.warn(appAttemptId + " is in " + state + " state, ignore container allocate request."); allocation = EMPTY_ALLOCATION; } else { allocation = this.rScheduler.allocate(appAttemptId, ask, release, blacklistAdditions, blacklistRemovals, increaseResourceReqs, decreaseResourceReqs); } if (!blacklistAdditions.isEmpty() || !blacklistRemovals.isEmpty()) { LOG.info("blacklist are updated in Scheduler." + "blacklistAdditions: " + blacklistAdditions + ", " + "blacklistRemovals: " + blacklistRemovals); } RMAppAttempt appAttempt = app.getRMAppAttempt(appAttemptId); AllocateResponse allocateResponse = recordFactory.newRecordInstance(AllocateResponse.class); if (!allocation.getContainers().isEmpty()) { allocateResponse.setNMTokens(allocation.getNMTokens()); } // Notify the AM of container update errors if (!updateContainerErrors.isEmpty()) { allocateResponse.setUpdateErrors(updateContainerErrors); } // update the response with the deltas of node status changes List<RMNode> updatedNodes = new ArrayList<RMNode>(); if (app.pullRMNodeUpdates(updatedNodes) > 0) { List<NodeReport> updatedNodeReports = new ArrayList<NodeReport>(); for (RMNode rmNode : updatedNodes) { SchedulerNodeReport schedulerNodeReport = rScheduler.getNodeReport(rmNode.getNodeID()); Resource used = BuilderUtils.newResource(0, 0); int numContainers = 0; if (schedulerNodeReport != null) { used = schedulerNodeReport.getUsedResource(); numContainers = schedulerNodeReport.getNumContainers(); } NodeId nodeId = rmNode.getNodeID(); NodeReport report = BuilderUtils.newNodeReport(nodeId, rmNode.getState(), rmNode.getHttpAddress(), rmNode.getRackName(), used, rmNode.getTotalCapability(), numContainers, rmNode.getHealthReport(), rmNode.getLastHealthReportTime(), rmNode.getNodeLabels()); updatedNodeReports.add(report); } allocateResponse.setUpdatedNodes(updatedNodeReports); } allocateResponse.setAllocatedContainers(allocation.getContainers()); allocateResponse.setCompletedContainersStatuses(appAttempt.pullJustFinishedContainers()); allocateResponse.setResponseId(lastResponse.getResponseId() + 1); allocateResponse.setAvailableResources(allocation.getResourceLimit()); // Handling increased/decreased containers List<UpdatedContainer> updatedContainers = new ArrayList<>(); if (allocation.getIncreasedContainers() != null) { for (Container c : allocation.getIncreasedContainers()) { updatedContainers.add(UpdatedContainer.newInstance(ContainerUpdateType.INCREASE_RESOURCE, c)); } } if (allocation.getDecreasedContainers() != null) { for (Container c : allocation.getDecreasedContainers()) { updatedContainers.add(UpdatedContainer.newInstance(ContainerUpdateType.DECREASE_RESOURCE, c)); } } allocateResponse.setUpdatedContainers(updatedContainers); allocateResponse.setNumClusterNodes(this.rScheduler.getNumClusterNodes()); // add preemption to the allocateResponse message (if any) allocateResponse.setPreemptionMessage(generatePreemptionMessage(allocation)); // Set application priority allocateResponse.setApplicationPriority(app.getApplicationSubmissionContext().getPriority()); // update AMRMToken if the token is rolled-up MasterKeyData nextMasterKey = this.rmContext.getAMRMTokenSecretManager().getNextMasterKeyData(); if (nextMasterKey != null && nextMasterKey.getMasterKey().getKeyId() != amrmTokenIdentifier.getKeyId()) { RMAppAttemptImpl appAttemptImpl = (RMAppAttemptImpl) appAttempt; Token<AMRMTokenIdentifier> amrmToken = appAttempt.getAMRMToken(); if (nextMasterKey.getMasterKey().getKeyId() != appAttemptImpl.getAMRMTokenKeyId()) { LOG.info("The AMRMToken has been rolled-over. Send new AMRMToken back" + " to application: " + applicationId); amrmToken = rmContext.getAMRMTokenSecretManager().createAndGetAMRMToken(appAttemptId); appAttemptImpl.setAMRMToken(amrmToken); } allocateResponse.setAMRMToken(org.apache.hadoop.yarn.api.records.Token.newInstance( amrmToken.getIdentifier(), amrmToken.getKind().toString(), amrmToken.getPassword(), amrmToken.getService().toString())); } /* * As we are updating the response inside the lock object so we don't * need to worry about unregister call occurring in between (which * removes the lock object). */ lock.setAllocateResponse(allocateResponse); return allocateResponse; } }
From source file:at.knowcenter.wag.egov.egiz.pdf.PDFPage.java
public static float findMinY(Pos[] coordinates) { float min = Float.POSITIVE_INFINITY; for (int i = 0; i < coordinates.length; i++) { if (coordinates[i].y < min) { min = coordinates[i].y;//from w ww . j av a 2 s . c o m } } return min; }
From source file:org.caleydo.view.domino.internal.Block.java
/** * *///from www. j a v a 2 s . c o m private void shiftToZero() { Vec2f offset = new Vec2f(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY); for (Node n : nodes()) { Vec2f l = n.getLocation(); if (l.x() < offset.x()) // && !n.isDetached(EDimension.RECORD)); offset.setX(l.x()); if (l.y() < offset.y()) // FIXME && !n.isDetached(EDimension.DIMENSION)) offset.setY(l.y()); } Node first = nodes().iterator().next(); Vec2f loc = first.getLocation(); if (offset.x() == 0 && offset.y() == 0) return; for (Node n : nodes()) { n.shiftLocation(-offset.x(), -offset.y()); } Vec2f loc_new = first.getLocation(); Vec2f shift = loc_new.minus(loc); shiftLocation(-shift.x(), -shift.y()); }