List of usage examples for java.lang Long MIN_VALUE
long MIN_VALUE
To view the source code for java.lang Long MIN_VALUE.
Click Source Link
From source file:org.apache.accumulo.tserver.tablet.Tablet.java
public Tablet(final TabletServer tabletServer, final KeyExtent extent, final TabletResourceManager trm, TabletData data) throws IOException { this.tabletServer = tabletServer; this.extent = extent; this.tabletResources = trm; this.lastLocation = data.getLastLocation(); this.lastFlushID = data.getFlushID(); this.lastCompactID = data.getCompactID(); this.splitCreationTime = data.getSplitTime(); this.tabletTime = TabletTime.getInstance(data.getTime()); this.persistedTime = tabletTime.getTime(); this.logId = tabletServer.createLogId(extent); TableConfiguration tblConf = tabletServer.getTableConfiguration(extent); if (null == tblConf) { Tables.clearCache(tabletServer.getInstance()); tblConf = tabletServer.getTableConfiguration(extent); requireNonNull(tblConf, "Could not get table configuration for " + extent.getTableId()); }// www .j av a 2 s. c o m this.tableConfiguration = tblConf; // translate any volume changes VolumeManager fs = tabletServer.getFileSystem(); boolean replicationEnabled = ReplicationConfigurationUtil.isEnabled(extent, this.tableConfiguration); TabletFiles tabletPaths = new TabletFiles(data.getDirectory(), data.getLogEntris(), data.getDataFiles()); tabletPaths = VolumeUtil.updateTabletVolumes(tabletServer, tabletServer.getLock(), fs, extent, tabletPaths, replicationEnabled); // deal with relative path for the directory Path locationPath; if (tabletPaths.dir.contains(":")) { locationPath = new Path(tabletPaths.dir); } else { locationPath = tabletServer.getFileSystem().getFullPath(FileType.TABLE, extent.getTableId() + tabletPaths.dir); } this.location = locationPath; this.tabletDirectory = tabletPaths.dir; for (Entry<Long, List<FileRef>> entry : data.getBulkImported().entrySet()) { this.bulkImported.put(entry.getKey(), new CopyOnWriteArrayList<FileRef>(entry.getValue())); } setupDefaultSecurityLabels(extent); final List<LogEntry> logEntries = tabletPaths.logEntries; final SortedMap<FileRef, DataFileValue> datafiles = tabletPaths.datafiles; tableConfiguration.addObserver(configObserver = new ConfigurationObserver() { private void reloadConstraints() { log.debug("Reloading constraints for extent: " + extent); constraintChecker.set(new ConstraintChecker(tableConfiguration)); } @Override public void propertiesChanged() { reloadConstraints(); try { setupDefaultSecurityLabels(extent); } catch (Exception e) { log.error("Failed to reload default security labels for extent: " + extent.toString()); } } @Override public void propertyChanged(String prop) { if (prop.startsWith(Property.TABLE_CONSTRAINT_PREFIX.getKey())) reloadConstraints(); else if (prop.equals(Property.TABLE_DEFAULT_SCANTIME_VISIBILITY.getKey())) { try { log.info("Default security labels changed for extent: " + extent.toString()); setupDefaultSecurityLabels(extent); } catch (Exception e) { log.error("Failed to reload default security labels for extent: " + extent.toString()); } } } @Override public void sessionExpired() { log.debug("Session expired, no longer updating per table props..."); } }); tableConfiguration.getNamespaceConfiguration().addObserver(configObserver); tabletMemory = new TabletMemory(this); // Force a load of any per-table properties configObserver.propertiesChanged(); if (!logEntries.isEmpty()) { log.info("Starting Write-Ahead Log recovery for " + this.extent); final AtomicLong entriesUsedOnTablet = new AtomicLong(0); // track max time from walog entries without timestamps final AtomicLong maxTime = new AtomicLong(Long.MIN_VALUE); final CommitSession commitSession = getTabletMemory().getCommitSession(); try { Set<String> absPaths = new HashSet<String>(); for (FileRef ref : datafiles.keySet()) absPaths.add(ref.path().toString()); tabletServer.recover(this.getTabletServer().getFileSystem(), extent, tableConfiguration, logEntries, absPaths, new MutationReceiver() { @Override public void receive(Mutation m) { // LogReader.printMutation(m); Collection<ColumnUpdate> muts = m.getUpdates(); for (ColumnUpdate columnUpdate : muts) { if (!columnUpdate.hasTimestamp()) { // if it is not a user set timestamp, it must have been set // by the system maxTime.set(Math.max(maxTime.get(), columnUpdate.getTimestamp())); } } getTabletMemory().mutate(commitSession, Collections.singletonList(m)); entriesUsedOnTablet.incrementAndGet(); } }); if (maxTime.get() != Long.MIN_VALUE) { tabletTime.useMaxTimeFromWALog(maxTime.get()); } commitSession.updateMaxCommittedTime(tabletTime.getTime()); if (entriesUsedOnTablet.get() == 0) { log.debug("No replayed mutations applied, removing unused entries for " + extent); MetadataTableUtil.removeUnusedWALEntries(getTabletServer(), extent, logEntries, tabletServer.getLock()); // No replication update to be made because the fact that this tablet didn't use any mutations // from the WAL implies nothing about use of this WAL by other tablets. Do nothing. logEntries.clear(); } else if (ReplicationConfigurationUtil.isEnabled(extent, tabletServer.getTableConfiguration(extent))) { // The logs are about to be re-used by this tablet, we need to record that they have data for this extent, // but that they may get more data. logEntries is not cleared which will cause the elements // in logEntries to be added to the currentLogs for this Tablet below. // // This update serves the same purpose as an update during a MinC. We know that the WAL was defined // (written when the WAL was opened) but this lets us know there are mutations written to this WAL // that could potentially be replicated. Because the Tablet is using this WAL, we can be sure that // the WAL isn't closed (WRT replication Status) and thus we're safe to update its progress. Status status = StatusUtil.openWithUnknownLength(); for (LogEntry logEntry : logEntries) { log.debug("Writing updated status to metadata table for " + logEntry.filename + " " + ProtobufUtil.toString(status)); ReplicationTableUtil.updateFiles(tabletServer, extent, logEntry.filename, status); } } } catch (Throwable t) { if (tableConfiguration.getBoolean(Property.TABLE_FAILURES_IGNORE)) { log.warn("Error recovering from log files: ", t); } else { throw new RuntimeException(t); } } // make some closed references that represent the recovered logs currentLogs = new ConcurrentSkipListSet<DfsLogger>(); for (LogEntry logEntry : logEntries) { currentLogs.add(new DfsLogger(tabletServer.getServerConfig(), logEntry.filename, logEntry.getColumnQualifier().toString())); } log.info("Write-Ahead Log recovery complete for " + this.extent + " (" + entriesUsedOnTablet.get() + " mutations applied, " + getTabletMemory().getNumEntries() + " entries created)"); } String contextName = tableConfiguration.get(Property.TABLE_CLASSPATH); if (contextName != null && !contextName.equals("")) { // initialize context classloader, instead of possibly waiting for it to initialize for a scan // TODO this could hang, causing other tablets to fail to load - ACCUMULO-1292 AccumuloVFSClassLoader.getContextManager().getClassLoader(contextName); } // do this last after tablet is completely setup because it // could cause major compaction to start datafileManager = new DatafileManager(this, datafiles); computeNumEntries(); getDatafileManager().removeFilesAfterScan(data.getScanFiles()); // look for hints of a failure on the previous tablet server if (!logEntries.isEmpty() || needsMajorCompaction(MajorCompactionReason.NORMAL)) { // look for any temp files hanging around removeOldTemporaryFiles(); } log.log(TLevel.TABLET_HIST, extent + " opened"); }
From source file:com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.java
protected boolean isInRange(Number value, String stringValue, Class toType) { Number bigValue = null;/*w ww. ja v a 2s .c om*/ Number lowerBound = null; Number upperBound = null; try { if (double.class == toType || Double.class == toType) { bigValue = new BigDecimal(stringValue); // Double.MIN_VALUE is the smallest positive non-zero number lowerBound = BigDecimal.valueOf(Double.MAX_VALUE).negate(); upperBound = BigDecimal.valueOf(Double.MAX_VALUE); } else if (float.class == toType || Float.class == toType) { bigValue = new BigDecimal(stringValue); // Float.MIN_VALUE is the smallest positive non-zero number lowerBound = BigDecimal.valueOf(Float.MAX_VALUE).negate(); upperBound = BigDecimal.valueOf(Float.MAX_VALUE); } else if (byte.class == toType || Byte.class == toType) { bigValue = new BigInteger(stringValue); lowerBound = BigInteger.valueOf(Byte.MIN_VALUE); upperBound = BigInteger.valueOf(Byte.MAX_VALUE); } else if (char.class == toType || Character.class == toType) { bigValue = new BigInteger(stringValue); lowerBound = BigInteger.valueOf(Character.MIN_VALUE); upperBound = BigInteger.valueOf(Character.MAX_VALUE); } else if (short.class == toType || Short.class == toType) { bigValue = new BigInteger(stringValue); lowerBound = BigInteger.valueOf(Short.MIN_VALUE); upperBound = BigInteger.valueOf(Short.MAX_VALUE); } else if (int.class == toType || Integer.class == toType) { bigValue = new BigInteger(stringValue); lowerBound = BigInteger.valueOf(Integer.MIN_VALUE); upperBound = BigInteger.valueOf(Integer.MAX_VALUE); } else if (long.class == toType || Long.class == toType) { bigValue = new BigInteger(stringValue); lowerBound = BigInteger.valueOf(Long.MIN_VALUE); upperBound = BigInteger.valueOf(Long.MAX_VALUE); } } catch (NumberFormatException e) { //shoult it fail here? BigInteger doesnt seem to be so nice parsing numbers as NumberFormat return true; } return ((Comparable) bigValue).compareTo(lowerBound) >= 0 && ((Comparable) bigValue).compareTo(upperBound) <= 0; }
From source file:org.apache.carbondata.core.indexstore.blockletindex.BlockletDataMap.java
/** * Fill the measures min values with minimum , this is needed for backward version compatability * as older versions don't store min values for measures *//*from w ww . j a v a 2 s . c om*/ private byte[][] updateMinValues(byte[][] minValues, int[] minMaxLen) { byte[][] updatedValues = minValues; if (minValues.length < minMaxLen.length) { updatedValues = new byte[minMaxLen.length][]; System.arraycopy(minValues, 0, updatedValues, 0, minValues.length); List<CarbonMeasure> measures = segmentProperties.getMeasures(); ByteBuffer buffer = ByteBuffer.allocate(8); for (int i = 0; i < measures.size(); i++) { buffer.rewind(); DataType dataType = measures.get(i).getDataType(); if (dataType == DataTypes.BYTE) { buffer.putLong(Byte.MIN_VALUE); updatedValues[minValues.length + i] = buffer.array().clone(); } else if (dataType == DataTypes.SHORT) { buffer.putLong(Short.MIN_VALUE); updatedValues[minValues.length + i] = buffer.array().clone(); } else if (dataType == DataTypes.INT) { buffer.putLong(Integer.MIN_VALUE); updatedValues[minValues.length + i] = buffer.array().clone(); } else if (dataType == DataTypes.LONG) { buffer.putLong(Long.MIN_VALUE); updatedValues[minValues.length + i] = buffer.array().clone(); } else if (DataTypes.isDecimal(dataType)) { updatedValues[minValues.length + i] = DataTypeUtil .bigDecimalToByte(BigDecimal.valueOf(Long.MIN_VALUE)); } else { buffer.putDouble(Double.MIN_VALUE); updatedValues[minValues.length + i] = buffer.array().clone(); } } } return updatedValues; }
From source file:com.streamsets.datacollector.definition.ConfigDefinitionExtractor.java
List<ErrorMessage> validateConfigDef(String configPrefix, List<String> stageGroups, Field field, boolean isComplexField, Object contextMsg) { List<ErrorMessage> errors = new ArrayList<>(); ConfigDef annotation = field.getAnnotation(ConfigDef.class); errors.addAll(ConfigValueExtractor.get().validate(field, annotation, contextMsg)); if (annotation.type() == ConfigDef.Type.MODEL && field.getAnnotation(ListBeanModel.class) != null && isComplexField) { errors.add(new ErrorMessage(DefinitionError.DEF_161, contextMsg, field.getName())); } else {/*from www. j av a 2s. c o m*/ List<ErrorMessage> modelErrors = ModelDefinitionExtractor.get() .validate(configPrefix + field.getName() + ".", field, contextMsg); if (modelErrors.isEmpty()) { ModelDefinition model = ModelDefinitionExtractor.get().extract(configPrefix + field.getName() + ".", field, contextMsg); errors.addAll(validateELFunctions(annotation, model, contextMsg)); errors.addAll(validateELConstants(annotation, model, contextMsg)); } else { errors.addAll(modelErrors); } if (annotation.type() != ConfigDef.Type.NUMBER && (annotation.min() != Long.MIN_VALUE || annotation.max() != Long.MAX_VALUE)) { errors.add(new ErrorMessage(DefinitionError.DEF_155, contextMsg, field.getName())); } errors.addAll(validateDependsOnName(configPrefix, annotation.dependsOn(), Utils.formatL("{} Field='{}'", contextMsg, field.getName()))); } return errors; }
From source file:io.s4.util.LoadGenerator.java
private long[] getRateInfo(long[] rateInfo) { long totalTimeNanos = 0; int entryCount = 0; for (int i = 0; i < processTimes.length; i++) { if (processTimes[i] == Long.MIN_VALUE) { break; }//w w w . j a va 2 s . c o m entryCount++; totalTimeNanos += processTimes[i]; } long averageTimeMicros = (long) ((totalTimeNanos / (double) entryCount) / 1000.0); // fudge the time for additional overhead averageTimeMicros += (long) (averageTimeMicros * 0.30); if (emitCount % 5000 == 0) { // System.out.println("Average time in micros is " + // averageTimeMicros); } long sleepTimeMicros = 0; long millis = 0; long timeToMeetRateMicros = adjustedExpectedRate * averageTimeMicros; long leftOver = 1000000 - timeToMeetRateMicros; if (leftOver <= 0) { sleepTimeMicros = 0; } else { sleepTimeMicros = (leftOver / adjustedExpectedRate) - sleepOverheadMicros; } // how many events can be processed in the nanos time? int eventsBeforeSleep = 1; if (sleepTimeMicros < 1000) { sleepTimeMicros = 1000 + sleepOverheadMicros; millis = 1; double numNapsDouble = ((double) leftOver / sleepTimeMicros); int numNaps = (int) Math.ceil(numNapsDouble); if (numNaps > 0) { eventsBeforeSleep = adjustedExpectedRate / numNaps; } if (leftOver <= 0) { millis = 0; eventsBeforeSleep = 1000; } } else { millis = sleepTimeMicros / 1000; } rateInfo[0] = millis; rateInfo[1] = eventsBeforeSleep; return rateInfo; }
From source file:com.projity.pm.criticalpath.TaskSchedule.java
public void assignDatesFromChildren(CalculationContext context) { Collection children = task.getWbsChildrenNodes(); if (children == null) return;/*from w ww .j a v a 2s. com*/ long begin = Long.MAX_VALUE; long end = Long.MIN_VALUE; Iterator i = children.iterator(); NormalTask child; Object current; TaskSchedule childSchedule; boolean estimated = false; int t = type; if (context != null && context.pass == 3) t = CURRENT; //System.out.println("assign from children top ass" + assign + " " + this); while (i.hasNext()) { current = ((Node) i.next()).getImpl(); if (!(current instanceof NormalTask)) continue; child = (NormalTask) current; estimated |= child.isEstimated(); // if (context != null && context.pass == 3 && child.isReverseScheduled()) { // // childSchedule = child.getSchedule(-type); // System.out.println("reverse " + child + " " + childSchedule); // } else childSchedule = child.getSchedule(t); // if (assign && child.isReverseScheduled()) // childSchedule = childSchedule.getOppositeSchedule(); long childBegin = childSchedule.getBegin(); if (childBegin != 0) begin = Math.min(begin, childBegin); long childEnd = childSchedule.getEnd(); if (childEnd != 0) end = Math.max(end, childEnd); } if (begin != Long.MAX_VALUE && begin != 0) // in case of invalid subproject having no children setBegin(begin); else { return; } if (end != Long.MIN_VALUE && end != 0) setEnd(end); else { return;// System.out.println("begin is " + new Date(begin) + " end " + new Date(end)); } long duration = task.getEffectiveWorkCalendar().compare(end, begin, false); duration = Duration.setAsEstimated(duration, estimated); ((NormalTask) task).setEstimated(estimated); setRawDuration(duration); }
From source file:com.nridge.core.base.field.Field.java
/** * Returns a <i>long</i> representation of the field * value string./*from w w w .ja v a2 s . co m*/ * * @param aValue Numeric string value. * * @return Converted value. */ public static long createLong(String aValue) { if (NumberUtils.isDigits(aValue)) return Long.parseLong(aValue); else return Long.MIN_VALUE; }
From source file:com.glaf.core.util.GetterUtils.java
public static long getLongStrict(String value) { int length = value.length(); if (length <= 0) { throw new NumberFormatException("Unable to parse " + value); }/*from w ww . j a v a2 s . c om*/ int index = 0; long limit = -Long.MAX_VALUE; boolean negative = false; char c = value.charAt(0); if (c < CharPool.NUMBER_0) { if (c == CharPool.MINUS) { limit = Long.MIN_VALUE; negative = true; } else if (c != CharPool.PLUS) { throw new NumberFormatException("Unable to parse " + value); } if (length == 1) { throw new NumberFormatException("Unable to parse " + value); } index++; } long smallLimit = limit / 10; long result = 0; while (index < length) { if (result < smallLimit) { throw new NumberFormatException("Unable to parse " + value); } c = value.charAt(index++); if ((c < CharPool.NUMBER_0) || (c > CharPool.NUMBER_9)) { throw new NumberFormatException("Unable to parse " + value); } int number = c - CharPool.NUMBER_0; result *= 10; if (result < (limit + number)) { throw new NumberFormatException("Unable to parse " + value); } result -= number; } if (negative) { return result; } else { return -result; } }
From source file:com.nridge.core.base.field.Field.java
/** * Returns a <i>Long</i> representation of the field * value string./*from www. j a v a 2s . c om*/ * * @param aValue Numeric string value. * * @return Converted value. */ public static Long createLongObject(String aValue) { if (NumberUtils.isDigits(aValue)) return Long.valueOf(aValue); else return Long.MIN_VALUE; }
From source file:gsn.webservice.standard.GSNWebServiceSkeleton.java
/** * Auto generated method signature/*from ww w .j av a 2s . co m*/ * * @param getMultiData */ public gsn.webservice.standard.GetMultiDataResponse getMultiData( gsn.webservice.standard.GetMultiData getMultiData) { //throw new java.lang.UnsupportedOperationException("Please implement " + this.getClass().getName() + "#getMultiData"); // User user = getUserForAC(getMultiData.getAcDetails()); // GetMultiDataResponse response = new GetMultiDataResponse(); // Map<String, String[]> requestParameters = new HashMap<String, String[]>(); // virtual sensor and field selection HashMap<String, ArrayList<String>> vsAndFields = buildSelection(getMultiData.getFieldSelector()); ArrayList<String> vsnames = new ArrayList<String>(); for (Map.Entry<String, ArrayList<String>> entry : vsAndFields.entrySet()) { if (!Main.getContainerConfig().isAcEnabled() || (user != null && (user.hasReadAccessRight(entry.getKey()) || user.isAdmin()))) { StringBuilder sb = new StringBuilder(); sb.append(entry.getKey()); for (String elt : entry.getValue()) { sb.append(":").append(elt); } vsnames.add(sb.toString()); } } requestParameters.put("vsname", vsnames.toArray(new String[] {})); // time format String timeFormat = getMultiData.getTimeFormat(); if (timeFormat != null) requestParameters.put("timeformat", new String[] { timeFormat }); ArrayList<String> critFields = new ArrayList<String>(); //from / to long from = getMultiData.getFrom(); long to = getMultiData.getTo(); for (String vsname : vsAndFields.keySet()) { if (from != java.lang.Long.MIN_VALUE) critFields.add("and::" + vsname + ":timed:ge:" + from); if (to != java.lang.Long.MIN_VALUE) critFields.add("and::" + vsname + ":timed:leq:" + to); } // conditions StandardCriterion[] standardCriteria = getMultiData.getConditions(); if (standardCriteria != null) { for (StandardCriterion criterion : standardCriteria) { HashMap<String, ArrayList<String>> selection = new HashMap<String, ArrayList<String>>(); if ("ALL".equalsIgnoreCase(criterion.getVsname())) { if ("ALL".equalsIgnoreCase(criterion.getField())) { // We add this criterion for all the virtual sensors and all their fields selection = vsAndFields; } else { //ArrayList<String> vss = fieldToVs.get(criterion.getField()); ArrayList<String> crit = new ArrayList<String>(); crit.add(criterion.getField()); for (Map.Entry<String, ArrayList<String>> entry : vsAndFields.entrySet()) { if (entry.getValue() != null && entry.getValue().contains(criterion.getField())) { selection.put(entry.getKey(), crit); } } } } else { ArrayList<String> _fields = vsAndFields.get(criterion.getVsname()); if (_fields != null) { if ("ALL".equalsIgnoreCase(criterion.getField())) { selection.put(criterion.getVsname(), _fields); } else { if (_fields.contains(criterion.getField())) { ArrayList<String> values = new ArrayList<String>(); values.add(criterion.getField()); selection.put(criterion.getVsname(), values); } } } } for (Map.Entry<String, ArrayList<String>> entry : selection.entrySet()) { String vsname = entry.getKey(); for (String field : entry.getValue()) { //<critJoin>:<negation>:<vsname>:<field>:<operator>:<value> StringBuilder sb = new StringBuilder(); sb.append(criterion.getCritJoin()); sb.append(":"); sb.append(criterion.getNegation()); sb.append(":"); sb.append(vsname); sb.append(":"); sb.append(field); sb.append(":"); sb.append(criterion.getOperator()); sb.append(":"); sb.append(criterion.getValue()); // critFields.add(sb.toString()); } } } } requestParameters.put("critfield", critFields.toArray(new String[] {})); // nb /*long nb = getMultiData.getNb(); if (nb != java.lang.Long.MIN_VALUE) // check if nb is set requestParameters.put("nb", new String[]{"0:" + nb}); */ int userNb = getMultiData.getNb(); if (userNb == java.lang.Integer.MIN_VALUE) userNb = java.lang.Integer.MAX_VALUE; else if (userNb < 0) userNb = 0; // aggregation AggregationCriterion aggregation = getMultiData.getAggregation(); if (aggregation != null) { aggregation.getTimeRange(); requestParameters.put("groupby", new String[] { new StringBuilder().append(aggregation.getTimeRange()) .append(":").append(aggregation.getGroupOperator()).toString() }); } // try { QueriesBuilder qbuilder = new QueriesBuilder(requestParameters); for (Map.Entry<String, AbstractQuery> entry : qbuilder.getSqlQueries().entrySet()) { // QuerySession session = generateSession(entry.getValue(), entry.getKey(), userNb); // GSNWebService_QueryResult result = getResult(session); // response.addQueryResult(result); } } catch (Exception e) { logger.warn(e.getMessage(), e); } // return response; }