Example usage for java.lang Long MIN_VALUE

List of usage examples for java.lang Long MIN_VALUE

Introduction

In this page you can find the example usage for java.lang Long MIN_VALUE.

Prototype

long MIN_VALUE

To view the source code for java.lang Long MIN_VALUE.

Click Source Link

Document

A constant holding the minimum value a long can have, -263.

Usage

From source file:org.apache.camel.component.file.remote.strategy.FtpChangedExclusiveReadLockStrategy.java

public boolean acquireExclusiveReadLock(GenericFileOperations<FTPFile> operations, GenericFile<FTPFile> file,
        Exchange exchange) throws Exception {
    boolean exclusive = false;

    LOG.trace("Waiting for exclusive read lock to file: " + file);

    long lastModified = Long.MIN_VALUE;
    long length = Long.MIN_VALUE;
    StopWatch watch = new StopWatch();

    while (!exclusive) {
        // timeout check
        if (timeout > 0) {
            long delta = watch.taken();
            if (delta > timeout) {
                CamelLogger.log(LOG, readLockLoggingLevel,
                        "Cannot acquire read lock within " + timeout + " millis. Will skip the file: " + file);
                // we could not get the lock within the timeout period, so return false
                return false;
            }//from  w ww . ja  va  2 s.  co  m
        }

        long newLastModified = 0;
        long newLength = 0;
        List<FTPFile> files;
        if (fastExistsCheck) {
            // use the absolute file path to only pickup the file we want to check, this avoids expensive
            // list operations if we have a lot of files in the directory
            LOG.trace("Using fast exists to update file information for {}", file);
            files = operations.listFiles(file.getAbsoluteFilePath());
        } else {
            LOG.trace(
                    "Using full directory listing to update file information for {}. Consider enabling fastExistsCheck option.",
                    file);
            // fast option not enabled, so list the directory and filter the file name
            files = operations.listFiles(file.getParent());
        }
        LOG.trace("List files {} found {} files", file.getAbsoluteFilePath(), files.size());
        for (FTPFile f : files) {
            if (f.getName().equals(file.getFileNameOnly())) {
                newLength = f.getSize();
                if (f.getTimestamp() != null) {
                    newLastModified = f.getTimestamp().getTimeInMillis();
                }
            }
        }

        LOG.trace("Previous last modified: " + lastModified + ", new last modified: " + newLastModified);
        LOG.trace("Previous length: " + length + ", new length: " + newLength);

        if (length >= minLength && (newLastModified == lastModified && newLength == length)) {
            LOG.trace("Read lock acquired.");
            exclusive = true;
        } else {
            // set new base file change information
            lastModified = newLastModified;
            length = newLength;

            boolean interrupted = sleep();
            if (interrupted) {
                // we were interrupted while sleeping, we are likely being shutdown so return false
                return false;
            }
        }
    }

    return exclusive;
}

From source file:org.apache.axis2.transport.http.server.DefaultConnectionListenerFailureHandler.java

/**
 * Create a new DefaultConnectionListenerFailureHandler
 *
 * @param retryDelay      millis to wait before retrying
 * @param successInterval millis after which an initial or retry attempt will be deemed a success, resetting retry count to 0
 * @param maxRetries      maximum number of retries allowed without a success, after which the listener will terminate
 *///  w  w w  . j  a va2 s . com
public DefaultConnectionListenerFailureHandler(int retryDelay, int successInterval, int maxRetries) {
    this.retryDelay = retryDelay;
    this.successInterval = successInterval;
    this.maxRetries = maxRetries;
    this.lastFailure = this.lastFirstFailure = Long.MIN_VALUE;
    this.numRetries = 0;
}

From source file:net.sf.jasperreports.data.cache.LongArrayStore.java

private void reset() {
    this.count = 0;

    this.min = Long.MAX_VALUE;
    this.max = Long.MIN_VALUE;

    this.runLengthStore.reset();
}

From source file:ninja.eivind.hotsreplayuploader.utils.StormHandler.java

private static long maxLastModified(File dir) {
    File[] files = getReplayDirectory(dir).listFiles();
    if (files == null || files.length < 1)
        return Long.MIN_VALUE;
    return Arrays.stream(files).mapToLong(File::lastModified).max().orElse(Long.MIN_VALUE);
}

From source file:com.codenvy.cas.util.LdapUtils.java

/**
 * Reads a Long value from the LdapEntry.
 *
 * @param ctx       the ldap entry/*  w ww. jav  a  2  s . c o m*/
 * @param attribute the attribute name
 * @return the long value
 */
public static Long getLong(final LdapEntry ctx, final String attribute) {
    return getLong(ctx, attribute, Long.MIN_VALUE);
}

From source file:br.com.blackhubos.eventozero.updater.assets.Asset.java

@SuppressWarnings("unchecked")
public static Optional<Asset> parseJsonObject(JSONObject jsonObject, MultiTypeFormatter formatter) {

    String url = null;/*  w w  w .  jav a 2  s . co  m*/
    String name = null;
    String downloadUrl = null;

    Date createdDate = null;
    Date updatedDate = null;

    long id = Long.MIN_VALUE;
    long size = Long.MIN_VALUE;
    long downloads = Long.MIN_VALUE;

    AssetState state = null;

    Optional<String> label = Optional.empty();

    Optional<Uploader> uploader = Optional.empty();
    // Obtem todos valores do JSON
    for (Map.Entry entries : (Set<Map.Entry>) jsonObject.entrySet()) {

        Object key = entries.getKey();
        Object value = entries.getValue();
        String valueString = String.valueOf(value);

        switch (AssetInput.parseObject(key)) {
        case URL: {
            // URL do Asset
            url = valueString;
            break;
        }
        case ID: {
            // Id do Asset
            id = Long.parseLong(valueString);
            break;
        }
        case BROWSER_DOWNLOAD_URL: {
            // Link de download
            downloadUrl = valueString;
            break;
        }
        case CREATED_AT: {
            // Data de criao
            if (formatter.canFormat(Date.class)) {
                Optional<Date> dateResult = formatter.format(valueString, Date.class);
                if (dateResult.isPresent()) {
                    createdDate = dateResult.get();
                }
            }
            break;
        }
        case UPDATED_AT: {
            // Data de atualizao
            if (formatter.canFormat(Date.class)) {
                Optional<Date> dateResult = formatter.format(valueString, Date.class);
                if (dateResult.isPresent()) {
                    updatedDate = dateResult.get();
                }
            }
            break;
        }
        case NAME: {
            // Nome
            name = valueString;
            break;
        }
        case DOWNLOAD_COUNT: {
            // Quantidade de downloads
            downloads = Long.parseLong(valueString);
            break;
        }

        case LABEL: {
            /** Rtulo (se houver, caso contrrio, {@link Optional#absent()}  **/
            if (value == null) {
                label = Optional.empty();
            } else {
                label = Optional.of(valueString);
            }
            break;
        }

        case STATE: {
            // Estado
            state = AssetState.parseString(valueString);
            break;
        }

        case SIZE: {
            // Tamanho do arquivo (em bytes)
            size = Long.parseLong(valueString);
            break;
        }

        case UPLOADER: {
            // Quem envou (traduzido externalmente)
            uploader = Uploader.parseJsonObject((JSONObject) value, formatter);
            break;
        }

        default: {
        }
        }
    }

    if (id == Long.MIN_VALUE) {
        // Retorna um optional de valor ausente se no for encontrado o Asset.
        return Optional.empty();
    }

    // Cria um novo Asset
    return Optional.of(new Asset(url, name, downloadUrl, createdDate, updatedDate, id, size, downloads, state,
            label, uploader));
}

From source file:com.basetechnology.s0.agentserver.field.IntField.java

public static Field fromJson(SymbolTable symbolTable, JSONObject fieldJson) {
    String type = fieldJson.optString("type");
    if (type == null || !(type.equals("int") || type.equals("integer")))
        return null;
    String name = fieldJson.has("name") ? fieldJson.optString("name") : null;
    String label = fieldJson.has("label") ? fieldJson.optString("label") : null;
    String description = fieldJson.has("description") ? fieldJson.optString("description") : null;
    long defaultValue = fieldJson.has("default_value") ? fieldJson.optLong("default_value") : 0;
    long minValue = fieldJson.has("min_value") ? fieldJson.optLong("min_value") : Long.MIN_VALUE;
    long maxValue = fieldJson.has("max_value") ? fieldJson.optLong("max_value") : Long.MAX_VALUE;
    int nominalWidth = fieldJson.has("nominal_width") ? fieldJson.optInt("nominal_width") : 0;
    String compute = fieldJson.has("compute") ? fieldJson.optString("compute") : null;
    return new IntField(symbolTable, name, label, description, defaultValue, minValue, maxValue, nominalWidth,
            compute);//from w  w  w.  ja v  a2s  . c  om
}

From source file:com.linkedin.pinot.core.segment.index.creator.SegmentGenerationWithTimeColumnTest.java

@BeforeMethod
public void reset() {
    minTime = Long.MAX_VALUE;
    maxTime = Long.MIN_VALUE;
    FileUtils.deleteQuietly(new File(SEGMENT_DIR_NAME));
}

From source file:net.myrrix.common.collection.FastIDSetTest.java

@Test
public void testReservedValues() {
    FastIDSet set = new FastIDSet();
    try {//from w  ww  .  ja v a2 s  .co  m
        set.add(Long.MIN_VALUE);
        fail("Should have thrown IllegalArgumentException");
    } catch (IllegalArgumentException iae) {
        // good
    }
    assertFalse(set.contains(Long.MIN_VALUE));
    try {
        set.add(Long.MAX_VALUE);
        fail("Should have thrown IllegalArgumentException");
    } catch (IllegalArgumentException iae) {
        // good
    }
    assertFalse(set.contains(Long.MAX_VALUE));
}

From source file:com.wabacus.system.task.TimingThread.java

public void reset() {
    this.lstTasks = null;
    this.lstTasksIds = null;
    this.intervalMilSeconds = Long.MIN_VALUE;
}