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:edu.usc.goffish.gofs.partition.PartitionTest.java

protected void comparePartitionInstances(IPartition actual) throws IOException {
    ISubgraph subgraph = actual.getSubgraph((8L | ((long) actual.getId()) << 32));

    // Retrieve all the instances
    {//from ww w . java  2 s  .c  o m
        // Read the graph instances for vertex and edge properties
        Iterable<? extends ISubgraphInstance> subgraphInstances = subgraph.getInstances(Long.MIN_VALUE,
                Long.MAX_VALUE, subgraph.getVertexProperties(), subgraph.getEdgeProperties(), false);
        assertNotNull(subgraphInstances);

        // Assert the instances of subgraph id '34', returns the property
        // value for vertex 338
        for (ISubgraphInstance instance : subgraphInstances) {
            // Vertex Properties
            ISubgraphObjectProperties propertiesForVertex = instance.getPropertiesForVertex(338);
            // Edge Properties
            ISubgraphObjectProperties propertiesForEdge = instance.getPropertiesForEdge(3);

            if (instance.getId() == 0) {
                assertEquals("3390,7430", propertiesForVertex.getValue("license-list"));
                assertEquals(5.77, propertiesForVertex.getValue("latitude"));
                assertEquals(16.22, propertiesForVertex.getValue("longitude"));
                assertEquals(12, propertiesForEdge.getValue("weight"));
            } else if (instance.getId() == 1) {
                assertEquals("3380,7420", propertiesForVertex.getValue("license-list"));
                assertEquals(11.56, propertiesForVertex.getValue("latitude"));
                assertEquals(17.67, propertiesForVertex.getValue("longitude"));
                assertEquals(16, propertiesForEdge.getValue("weight"));
            }

        }
    }

    // Retrieve instance for the time range
    {
        // Start Time - 1367012492282
        // End Time - 1367012792282
        // Instance id - 0
        Iterable<? extends ISubgraphInstance> subgraphInstances = subgraph.getInstances(1367012492282L,
                1367012792282L, subgraph.getVertexProperties(), subgraph.getEdgeProperties(), false);
        assertNotNull(subgraphInstances);
        // Assert the instances of subgraph id '34', returns the property
        // value for vertex 339
        for (ISubgraphInstance instance : subgraphInstances) {
            // Vertex Properties
            ISubgraphObjectProperties propertiesForVertex = instance.getPropertiesForVertex(339);
            // Edge Properties
            ISubgraphObjectProperties propertiesForEdge = instance.getPropertiesForEdge(3);
            assertEquals("3320,3380", propertiesForVertex.getValue("license-list"));
            assertEquals(5.77, propertiesForVertex.getValue("latitude"));
            assertEquals(16.22, propertiesForVertex.getValue("longitude"));
            assertEquals(12, propertiesForEdge.getValue("weight"));
        }
    }
}

From source file:edu.utexas.quietplaces.services.PlacesUpdateService.java

/**
 * {@inheritDoc}//from  ww  w  .  j a va  2 s .c o  m
 * Checks the battery and connectivity state before removing stale venues
 * and initiating a server poll for new venues around the specified
 * location within the given radius.
 */
@Override
protected void onHandleIntent(Intent intent) {
    // Check if we're running in the foreground, if not, check if
    // we have permission to do background updates.
    //noinspection deprecation
    boolean backgroundAllowed = cm.getBackgroundDataSetting();
    boolean inBackground = prefs.getBoolean(PlacesConstants.EXTRA_KEY_IN_BACKGROUND, true);

    if (!backgroundAllowed && inBackground)
        return;

    // Extract the location and radius around which to conduct our search.
    Location location = new Location(PlacesConstants.CONSTRUCTED_LOCATION_PROVIDER);
    int radius = PlacesConstants.PLACES_SEARCH_RADIUS;

    Bundle extras = intent.getExtras();
    if (intent.hasExtra(PlacesConstants.EXTRA_KEY_LOCATION)) {
        location = (Location) (extras.get(PlacesConstants.EXTRA_KEY_LOCATION));
        radius = extras.getInt(PlacesConstants.EXTRA_KEY_RADIUS, PlacesConstants.PLACES_SEARCH_RADIUS);
    }

    // Check if we're in a low battery situation.
    IntentFilter batIntentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    Intent battery = registerReceiver(null, batIntentFilter);
    lowBattery = getIsLowBattery(battery);

    // Check if we're connected to a data network, and if so - if it's a mobile network.
    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
    boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
    mobileData = activeNetwork != null && activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE;

    // If we're not connected, enable the connectivity receiver and disable the location receiver.
    // There's no point trying to poll the server for updates if we're not connected, and the
    // connectivity receiver will turn the location-based updates back on once we have a connection.
    if (!isConnected) {
        Log.w(TAG, "Not connected!");
    } else {
        // If we are connected check to see if this is a forced update (typically triggered
        // when the location has changed).
        boolean doUpdate = intent.getBooleanExtra(PlacesConstants.EXTRA_KEY_FORCEREFRESH, false);

        // If it's not a forced update (for example from the Activity being restarted) then
        // check to see if we've moved far enough, or there's been a long enough delay since
        // the last update and if so, enforce a new update.
        if (!doUpdate) {
            // Retrieve the last update time and place.
            long lastTime = prefs.getLong(PlacesConstants.SP_KEY_LAST_LIST_UPDATE_TIME, Long.MIN_VALUE);
            float lastLat;
            try {
                lastLat = prefs.getFloat(PlacesConstants.SP_KEY_LAST_LIST_UPDATE_LAT, Float.MIN_VALUE);
            } catch (ClassCastException e) {
                // handle legacy version
                lastLat = Float.MIN_VALUE;
            }
            float lastLng;
            try {
                lastLng = prefs.getFloat(PlacesConstants.SP_KEY_LAST_LIST_UPDATE_LNG, Float.MIN_VALUE);
            } catch (ClassCastException e) {
                lastLng = Float.MIN_VALUE;
            }
            Location lastLocation = new Location(PlacesConstants.CONSTRUCTED_LOCATION_PROVIDER);
            lastLocation.setLatitude(lastLat);
            lastLocation.setLongitude(lastLng);

            long currentTime = System.currentTimeMillis();
            float distanceMovedSinceLast = lastLocation.distanceTo(location);
            long elapsedTime = currentTime - lastTime;

            Log.i(TAG, "Last Location in places update service: " + lastLocation + " distance to current: "
                    + distanceMovedSinceLast + " - current: " + location);

            if (location == null) {
                Log.w(TAG, "Location is null...");
            }
            // If update time and distance bounds have been passed, do an update.
            else if (lastTime < currentTime - PlacesConstants.MAX_TIME_BETWEEN_PLACES_UPDATE) {
                Log.i(TAG, "Time bounds passed on places update, " + elapsedTime / 1000 + "s elapsed");
                doUpdate = true;
            } else if (distanceMovedSinceLast > PlacesConstants.MIN_DISTANCE_TRIGGER_PLACES_UPDATE) {
                Log.i(TAG, "Distance bounds passed on places update, moved: " + distanceMovedSinceLast
                        + " meters, time elapsed:  " + elapsedTime / 1000 + "s");
                doUpdate = true;
            } else {
                Log.d(TAG, "Time/distance bounds not passed on places update. Moved: " + distanceMovedSinceLast
                        + " meters, time elapsed: " + elapsedTime / 1000 + "s");
            }
        }

        if (location == null) {
            Log.e(TAG, "null location in onHandleIntent");
        } else if (doUpdate) {
            // Refresh the prefetch count for each new location.
            prefetchCount = 0;
            // Remove the old locations - TODO: we flush old locations, but if the next request
            // fails we are left high and dry
            removeOldLocations(location, radius);
            // Hit the server for new venues for the current location.
            refreshPlaces(location, radius, null);

            // Tell the main activity about the new results.
            Intent placesUpdatedIntent = new Intent(Config.ACTION_PLACES_UPDATED);
            LocalBroadcastManager.getInstance(this).sendBroadcast(placesUpdatedIntent);

        } else {
            Log.i(TAG, "Place List is fresh: Not refreshing");
        }

        // Retry any queued checkins.
        /*
                    Intent checkinServiceIntent = new Intent(this, PlaceCheckinService.class);
                    startService(checkinServiceIntent);
        */
    }
    Log.d(TAG, "Place List Download Service Complete");
}

From source file:com.opengamma.util.timeseries.fast.longint.FastArrayLongDoubleTimeSeries.java

@Override
public FastLongDoubleTimeSeries subSeriesFast(final long startTime, final long endTime) {
    if (isEmpty()) {
        return EMPTY_SERIES;
    }//from  w  w  w.  j  a  va 2s  . co  m
    // throw new NoSuchElementException("Series is empty")
    int startPos = Arrays.binarySearch(_times, startTime);
    int endPos = (endTime == Long.MIN_VALUE) ? _times.length : Arrays.binarySearch(_times, endTime);
    // if either is -1, make it zero
    startPos = startPos >= 0 ? startPos : -startPos - 1;
    endPos = endPos >= 0 ? endPos : -endPos - 1;
    final int length = endPos - startPos;
    if (endPos >= _times.length) {
        endPos--;
    }
    final long[] resultTimes = new long[length];
    final double[] resultValues = new double[length];
    System.arraycopy(_times, startPos, resultTimes, 0, length);
    System.arraycopy(_values, startPos, resultValues, 0, length);
    return new FastArrayLongDoubleTimeSeries(getEncoding(), resultTimes, resultValues);
}

From source file:com.bitium.confluence.config.ConfigureAction.java

public String doDefault() throws Exception {
    setLoginUrl(saml2Config.getLoginUrl());
    setLogoutUrl(saml2Config.getLogoutUrl());
    setEntityId(saml2Config.getIdpEntityId());
    setX509Certificate(saml2Config.getX509Certificate());
    setRedirectUrl(saml2Config.getRedirectUrl());
    long maxAuthenticationAge = saml2Config.getMaxAuthenticationAge();

    //Default Value
    if (maxAuthenticationAge == Long.MIN_VALUE) {
        setMaxAuthenticationAge("7200");
    }//from  ww w  .  j a v a  2  s .co  m
    //Stored Value
    else {
        setMaxAuthenticationAge(String.valueOf(maxAuthenticationAge));
    }

    String idpRequired = saml2Config.getIdpRequired();

    if (idpRequired != null) {
        setIdpRequired(idpRequired);
    } else {
        setIdpRequired("false");
    }

    String autoCreateUser = saml2Config.getAutoCreateUser();
    if (autoCreateUser != null) {
        setAutoCreateUser(autoCreateUser);
    } else {
        setAutoCreateUser("false");
    }

    String defaultAutocreateUserGroup = saml2Config.getAutoCreateUserDefaultGroup();
    if (defaultAutocreateUserGroup.isEmpty()) {
        // NOTE: Set the default to "confluence-users".
        // This is used when configuring the plugin for the first time and no default was set
        defaultAutocreateUserGroup = SAMLConfluenceConfig.DEFAULT_AUTOCREATE_USER_GROUP;
    }
    setDefaultAutoCreateUserGroup(defaultAutocreateUserGroup);
    return super.doDefault();
}

From source file:com.tilab.fiware.metaware.service.DataSourceServiceTest.java

/**
 * Test of createDataSource method, of class DataSourceService.
 *//*from  w  ww. j  a  va2s  .  c  o m*/
@Test
public void testCreateDataSource() {
    System.out.println("createDataSource");
    DataSource datasource = new DataSource("datasource test", "this is just a test", "test type",
            Long.MIN_VALUE, Long.MIN_VALUE, null, null, "test status", "test subtype",
            "jdbc:mysql://localhost/test", "testUsername", "superSecret", "query", "SELECT * FROM TEST");
    DataSourceService instance = new DataSourceService();
    datasource.setPermissions(Arrays.asList(perm1));
    datasource.setOwner(userId2);
    DataSource expResult = datasource;
    String datasId = instance.createDataSource(datasource);
    DataSource result = instance.getDataSource(datasId);
    assertEquals(expResult, result);
    instance.deleteDataSource(datasId);
}

From source file:edu.usc.goffish.gofs.itest.KryoSerializerIntegrationTest.java

protected void comparePartitionInstances(IPartition actual) throws IOException {
    ISubgraph subgraph = actual.getSubgraph(34);

    // Retrieve all the instances
    {//w ww .  ja v a  2  s  .c om
        // Read the graph instances for vertex and edge properties
        Iterable<? extends ISubgraphInstance> subgraphInstances = subgraph.getInstances(Long.MIN_VALUE,
                Long.MAX_VALUE, subgraph.getVertexProperties(), subgraph.getEdgeProperties(), false);
        assertNotNull(subgraphInstances);

        // Assert the instances of subgraph id '34', returns the property
        // value for vertex 338
        for (ISubgraphInstance instance : subgraphInstances) {
            // Vertex Properties
            ISubgraphObjectProperties propertiesForVertex = instance.getPropertiesForVertex(338);
            // Edge Properties
            ISubgraphObjectProperties propertiesForEdge = instance.getPropertiesForEdge(3);

            if (instance.getId() == 0) {
                assertEquals("3390,7430", propertiesForVertex.getValue("license-list"));
                assertEquals(5.77, propertiesForVertex.getValue("latitude"));
                assertEquals(16.22, propertiesForVertex.getValue("longitude"));
                assertEquals(12, propertiesForEdge.getValue("weight"));
            } else if (instance.getId() == 1) {
                assertEquals("3380,7420", propertiesForVertex.getValue("license-list"));
                assertEquals(11.56, propertiesForVertex.getValue("latitude"));
                assertEquals(17.67, propertiesForVertex.getValue("longitude"));
                assertEquals(16, propertiesForEdge.getValue("weight"));
            }

        }
    }

    // Retrieve instance for the time range
    {
        // Start Time - 1367012492282
        // End Time - 1367012792282
        // Instance id - 0
        Iterable<? extends ISubgraphInstance> subgraphInstances = subgraph.getInstances(1367012492282L,
                1367012792282L, subgraph.getVertexProperties(), subgraph.getEdgeProperties(), false);
        assertNotNull(subgraphInstances);
        // Assert the instances of subgraph id '34', returns the property
        // value for vertex 339
        for (ISubgraphInstance instance : subgraphInstances) {
            // Vertex Properties
            ISubgraphObjectProperties propertiesForVertex = instance.getPropertiesForVertex(339);
            // Edge Properties
            ISubgraphObjectProperties propertiesForEdge = instance.getPropertiesForEdge(3);
            assertEquals("3320,3380", propertiesForVertex.getValue("license-list"));
            assertEquals(5.77, propertiesForVertex.getValue("latitude"));
            assertEquals(16.22, propertiesForVertex.getValue("longitude"));
            assertEquals(12, propertiesForEdge.getValue("weight"));
        }
    }
}

From source file:com.kakao.helper.SharedPreferencesCache.java

public synchronized Date getDate(final String key) {
    long value = getLong(key);
    return (value == Long.MIN_VALUE) ? null : new Date(value);
}

From source file:com.linkedin.pinot.transport.perf.ScatterGatherPerfTester.java

public void run() throws Exception {

    List<ScatterGatherPerfServer> servers = null;

    // Run Servers when mode is RUN_SERVER or RUN_BOTH
    if (_mode != ExecutionMode.RUN_CLIENT) {
        servers = runServer();/*from   w w w  . j  a v a 2 s.  co m*/
    }

    if (_mode != ExecutionMode.RUN_SERVER) {
        int port = _startPortNum;
        // Setup Routing config for clients
        RoutingTableConfig config = new RoutingTableConfig();
        Map<String, PerTableRoutingConfig> cfg = config.getPerTableRoutingCfg();
        PerTableRoutingConfig c = new PerTableRoutingConfig(null);
        Map<Integer, List<ServerInstance>> instanceMap = c.getNodeToInstancesMap();
        port = _startPortNum;

        int numUniqueServers = _remoteServerHosts.size();

        for (int i = 0; i < _numServers; i++) {
            List<ServerInstance> instances = new ArrayList<ServerInstance>();
            String server = null;
            if (_mode == ExecutionMode.RUN_BOTH)
                server = "localhost";
            else
                server = _remoteServerHosts.get(i % numUniqueServers);
            ServerInstance instance = new ServerInstance(server, port++);
            instances.add(instance);
            instanceMap.put(i, instances);
        }
        String server = null;
        if (_mode == ExecutionMode.RUN_BOTH)
            server = "localhost";
        else
            server = _remoteServerHosts.get(0);
        c.getDefaultServers().add(new ServerInstance(server, port - 1));
        cfg.put(_resourceName, c);

        System.out.println("Routing Config is :" + cfg);

        // Build Clients
        List<Thread> clientThreads = new ArrayList<Thread>();
        List<ScatterGatherPerfClient> clients = new ArrayList<ScatterGatherPerfClient>();
        AggregatedHistogram<Histogram> latencyHistogram = new AggregatedHistogram<Histogram>();
        for (int i = 0; i < _numClients; i++) {
            ScatterGatherPerfClient c2 = new ScatterGatherPerfClient(config, _requestSize, _resourceName,
                    _asyncRequestDispatch, _numRequests, _maxActiveConnectionsPerClientServerPair,
                    _numResponseReaderThreads);
            Thread t = new Thread(c2);
            clients.add(c2);
            latencyHistogram.add(c2.getLatencyHistogram());
            clientThreads.add(t);
        }

        System.out.println("Starting the clients !!");
        long startTimeMs = 0;
        // Start Clients
        for (Thread t2 : clientThreads)
            t2.start();

        System.out.println("Waiting for clients to finish");

        // Wait for clients to finish
        for (Thread t2 : clientThreads)
            t2.join();

        Thread.sleep(3000);

        System.out.println("Client threads done !!");

        int totalRequestsMeasured = 0;
        long beginRequestTime = Long.MAX_VALUE;
        long endResponseTime = Long.MIN_VALUE;
        for (ScatterGatherPerfClient c3 : clients) {
            int numRequestsMeasured = c3.getNumRequestsMeasured();
            totalRequestsMeasured += numRequestsMeasured;
            beginRequestTime = Math.min(beginRequestTime, c3.getBeginFirstRequestTime());
            endResponseTime = Math.max(endResponseTime, c3.getEndLastResponseTime());
            //System.out.println("2 Num Requests :" + numRequestsMeasured);
            //System.out.println("2 time :" + timeTakenMs );
            //System.out.println("2 Throughput (Requests/Second) :" + ((numRequestsMeasured* 1.0 * 1000)/timeTakenMs));
        }
        long totalTimeTakenMs = endResponseTime - beginRequestTime;
        System.out.println("Overall Total Num Requests :" + totalRequestsMeasured);
        System.out.println("Overall Total time :" + totalTimeTakenMs);
        System.out.println("Overall Throughput (Requests/Second) :"
                + ((totalRequestsMeasured * 1.0 * 1000) / totalTimeTakenMs));
        latencyHistogram.refresh();
        System.out.println("Latency :" + new LatencyMetric<AggregatedHistogram<Histogram>>(latencyHistogram));
    }

    if (_mode == ExecutionMode.RUN_BOTH) {
        // Shutdown Servers
        for (ScatterGatherPerfServer s : servers) {
            s.shutdown();
        }
    }
}

From source file:simx.profiler.info.application.ActorsInfoTopComponent.java

public ActorsInfoTopComponent() {
    initComponents();/* w ww .  ja v  a2s  .c o  m*/
    setName(Bundle.CTL_ActorsInfoTopComponent());
    setToolTipText(Bundle.HINT_ActorsInfoTopComponent());

    this.content = new InstanceContent();

    this.associateLookup(new AbstractLookup(this.content));

    this.profilingData = ProfilingData.getLoadedProfilingData();
    final Map<MessageType, Integer> applicationCommunicationDataLocal = new HashMap<>();
    this.profilingData.getMessageTypes().stream().forEach((messageType) -> {
        applicationCommunicationDataLocal.put(messageType, messageType.getTimesSent());
    });
    this.applicationCommunicationData = new CommunicationData(new ImmutableTupel<>(null, null),
            applicationCommunicationDataLocal);
    this.content.set(Collections.singleton(this.applicationCommunicationData), null);

    this.actorTypes = this.profilingData.getActorTypes();
    this.actorTypeInformationTable.setModel(new ActorTypeInformationTableModel(this.profilingData));
    ListSelectionModel listSelectionModel = this.actorTypeInformationTable.getSelectionModel();
    listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listSelectionModel.addListSelectionListener((final ListSelectionEvent e) -> {
        setSelectedActorType(actorTypes.get(actorTypeInformationTable.getSelectedRow()));
    });
    this.actorInstances = profilingData.getActorInstances();
    listSelectionModel = this.actorInstanceInformationTable.getSelectionModel();
    listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listSelectionModel.addListSelectionListener((ListSelectionEvent e) -> {
        final ActorInstance actorInstance = actorInstances.get(actorInstanceInformationTable.getSelectedRow());
        setSelectedActorInstance(actorInstance);
    });
    this.actorInstanceInformationTable.setModel(new ActorInstanceInformationTableModel(this.profilingData));

    long minProcessingTime = Long.MAX_VALUE;
    long maxProcessingTime = Long.MIN_VALUE;

    for (final ActorType type : this.actorTypes) {
        if (type.getOverallProcessingTime() < minProcessingTime)
            minProcessingTime = type.getOverallProcessingTime();
        if (type.getOverallProcessingTime() > maxProcessingTime)
            maxProcessingTime = type.getOverallProcessingTime();
    }

    final Map<ImmutableTupel<ActorType, ActorType>, Integer> typeCommunicationScaleFactors = new HashMap<>();
    int minMessagesCount = Integer.MAX_VALUE;
    int maxMessagesCount = Integer.MIN_VALUE;
    for (final ActorType actorType : this.actorTypes) {
        final Map<ActorType, Map<MessageType, Integer>> s = actorType.getReceiverStatistics();
        for (final Map.Entry<ActorType, Map<MessageType, Integer>> e : s.entrySet()) {
            int count = 0;
            count = e.getValue().entrySet().stream().map((d) -> d.getValue()).reduce(count, Integer::sum);
            typeCommunicationScaleFactors.put(new ImmutableTupel<>(actorType, e.getKey()), count);
            if (count < minMessagesCount)
                minMessagesCount = count;
            if (count > maxMessagesCount)
                maxMessagesCount = count;
        }
    }

    int messagesSpan = maxMessagesCount - minMessagesCount;
    for (final Map.Entry<ImmutableTupel<ActorType, ActorType>, Integer> e : typeCommunicationScaleFactors
            .entrySet()) {
        final int factor = (((e.getValue() - minMessagesCount) * 4) / messagesSpan) + 1;
        typeCommunicationScaleFactors.put(e.getKey(), factor);
    }

    double timeSpan = maxProcessingTime - minProcessingTime;

    final Map<ActorType, Double> typeComputationScaleFactors = new HashMap<>();
    for (final ActorType type : this.actorTypes) {
        typeComputationScaleFactors.put(type,
                ((double) (type.getOverallProcessingTime() - minProcessingTime) * 0.4 / timeSpan) + 0.6);
    }

    final ActorTypeGraphScene actorTypeGraphScene = new ActorTypeGraphScene(this, typeComputationScaleFactors,
            typeCommunicationScaleFactors);
    actorTypeGraphScene.addObjectSceneListener(new ObjectSceneListener() {

        @Override
        public void objectAdded(final ObjectSceneEvent ose, final Object o) {
        }

        @Override
        public void objectRemoved(final ObjectSceneEvent ose, final Object o) {
        }

        @Override
        public void objectStateChanged(final ObjectSceneEvent ose, final Object o, final ObjectState os,
                final ObjectState os1) {
        }

        @Override
        public void selectionChanged(final ObjectSceneEvent ose, final Set<Object> oldSelection,
                final Set<Object> newSelection) {
            boolean communicationDataSet = false;
            for (final Object o : newSelection) {
                if (o instanceof ActorType)
                    setSelectedActorType((ActorType) o);
                if (o instanceof CommunicationData) {
                    setSelectedCommunicationData((CommunicationData) o);
                    communicationDataSet = true;
                }
            }
            if (!communicationDataSet)
                setSelectedCommunicationData(null);
        }

        @Override
        public void highlightingChanged(final ObjectSceneEvent ose, final Set<Object> set,
                final Set<Object> set1) {
        }

        @Override
        public void hoverChanged(final ObjectSceneEvent ose, final Object o, final Object o1) {
        }

        @Override
        public void focusChanged(final ObjectSceneEvent ose, final Object o, final Object o1) {
        }
    }, ObjectSceneEventType.OBJECT_SELECTION_CHANGED);
    this.typeScrollPane.setViewportView(actorTypeGraphScene.createView());

    this.actorTypes.stream().forEach((actorType) -> {
        actorTypeGraphScene.addNode(actorType);
    });
    this.actorTypes.stream().forEach((actorType) -> {
        final Map<ActorType, Map<MessageType, Integer>> s = actorType.getReceiverStatistics();
        s.entrySet().stream().forEach((e) -> {
            final CommunicationData edge = new CommunicationData(new ImmutableTupel<>(actorType, e.getKey()),
                    e.getValue());
            actorTypeGraphScene.addEdge(edge);
            actorTypeGraphScene.setEdgeSource(edge, actorType);
            actorTypeGraphScene.setEdgeTarget(edge, e.getKey());
        });
    });

    minProcessingTime = Long.MAX_VALUE;
    maxProcessingTime = Long.MIN_VALUE;

    for (final ActorInstance instance : this.actorInstances) {
        if (instance.getOverallProcessingTime() < minProcessingTime)
            minProcessingTime = instance.getOverallProcessingTime();
        if (instance.getOverallProcessingTime() > maxProcessingTime)
            maxProcessingTime = instance.getOverallProcessingTime();
    }

    timeSpan = maxProcessingTime - minProcessingTime;

    final Map<ImmutableTupel<ActorInstance, ActorInstance>, Integer> instanceCommunicationScaleFactors = new HashMap<>();
    minMessagesCount = Integer.MAX_VALUE;
    maxMessagesCount = Integer.MIN_VALUE;
    for (final ActorInstance instance : this.actorInstances) {
        final Map<ActorInstance, Map<MessageType, Integer>> s = instance.getReceiverStatistics();
        for (final Map.Entry<ActorInstance, Map<MessageType, Integer>> e : s.entrySet()) {
            int count = 0;
            count = e.getValue().entrySet().stream().map((d) -> d.getValue()).reduce(count, Integer::sum);
            instanceCommunicationScaleFactors.put(new ImmutableTupel<>(instance, e.getKey()), count);
            if (count < minMessagesCount)
                minMessagesCount = count;
            if (count > maxMessagesCount)
                maxMessagesCount = count;
        }
    }

    messagesSpan = maxMessagesCount - minMessagesCount;
    for (final Map.Entry<ImmutableTupel<ActorInstance, ActorInstance>, Integer> e : instanceCommunicationScaleFactors
            .entrySet()) {
        final int factor = (((e.getValue() - minMessagesCount) * 4) / messagesSpan) + 1;
        instanceCommunicationScaleFactors.put(e.getKey(), factor);
    }

    final Map<ActorInstance, Double> instanceComputationScaleFactors = new HashMap<>();
    for (final ActorInstance instance : this.actorInstances) {
        instanceComputationScaleFactors.put(instance,
                ((double) (instance.getOverallProcessingTime() - minProcessingTime) * 0.4 / timeSpan) + 0.6);
    }
    final ActorInstanceGraphScene actorInstanceGraphScene = new ActorInstanceGraphScene(this,
            instanceComputationScaleFactors, instanceCommunicationScaleFactors);

    actorInstanceGraphScene.addObjectSceneListener(new ObjectSceneListener() {

        @Override
        public void objectAdded(final ObjectSceneEvent ose, final Object o) {
        }

        @Override
        public void objectRemoved(final ObjectSceneEvent ose, final Object o) {
        }

        @Override
        public void objectStateChanged(final ObjectSceneEvent ose, final Object o, final ObjectState os,
                final ObjectState os1) {
        }

        @Override
        public void selectionChanged(final ObjectSceneEvent ose, final Set<Object> oldSelection,
                final Set<Object> newSelection) {
            boolean communicationDataSet = false;
            for (final Object o : newSelection) {
                if (o instanceof ActorInstance)
                    setSelectedActorInstance((ActorInstance) o);
                if (o instanceof CommunicationData) {
                    setSelectedCommunicationData((CommunicationData) o);
                    communicationDataSet = true;
                }
            }
            if (!communicationDataSet)
                setSelectedCommunicationData(null);
        }

        @Override
        public void highlightingChanged(final ObjectSceneEvent ose, final Set<Object> set,
                final Set<Object> set1) {
        }

        @Override
        public void hoverChanged(final ObjectSceneEvent ose, final Object o, final Object o1) {
        }

        @Override
        public void focusChanged(final ObjectSceneEvent ose, final Object o, final Object o1) {
        }
    }, ObjectSceneEventType.OBJECT_SELECTION_CHANGED);

    this.instancesScrollPane.setViewportView(actorInstanceGraphScene.createView());
    this.actorInstances.stream().forEach((actorInstance) -> {
        actorInstanceGraphScene.addNode(actorInstance);
    });
    this.actorInstances.stream().forEach((actorInstance) -> {
        final Map<ActorInstance, Map<MessageType, Integer>> s = actorInstance.getReceiverStatistics();
        s.entrySet().stream().forEach((e) -> {
            final CommunicationData edge = new CommunicationData(
                    new ImmutableTupel<>(actorInstance, e.getKey()), e.getValue());
            actorInstanceGraphScene.addEdge(edge);
            actorInstanceGraphScene.setEdgeSource(edge, actorInstance);
            actorInstanceGraphScene.setEdgeTarget(edge, e.getKey());
        });
    });

    this.dopPlotData = new XYSeriesCollection();
    JFreeChart dopChart = ChartFactory.createXYLineChart("", "", "", this.dopPlotData);
    final ChartPanel dopChartPanel = new ChartPanel(dopChart);
    dopChartPanel.setPreferredSize(new java.awt.Dimension(261, 157));
    this.dopPanel.setLayout(new BorderLayout());
    this.dopPanel.add(dopChartPanel, BorderLayout.CENTER);

    final XYSeries plotData = new XYSeries("Degree of Parallelism");

    final List<ParallelismEvent> parallelismEvents = this.profilingData.getParallelismEvents();
    Collections.sort(parallelismEvents);
    int parallelismLevel = 1;
    long lastTimeStamp = parallelismEvents.get(0).timestamp;
    final long firstTimeStamp = lastTimeStamp;
    final Map<Integer, Long> histogramData = new HashMap<>();
    plotData.add(0, 1);
    for (int i = 1; i < parallelismEvents.size(); ++i) {
        if (histogramData.containsKey(parallelismLevel)) {
            final long old = histogramData.get(parallelismLevel);
            histogramData.put(parallelismLevel, parallelismEvents.get(i).timestamp - lastTimeStamp + old);
        } else {
            histogramData.put(parallelismLevel, parallelismEvents.get(i).timestamp - lastTimeStamp);
        }
        lastTimeStamp = parallelismEvents.get(i).timestamp;
        if (parallelismEvents.get(i).eventType == ParallelismEvent.ParallelimEventTypes.PROCESSING_START) {
            ++parallelismLevel;
        } else {
            --parallelismLevel;
        }
        plotData.add((double) (lastTimeStamp - firstTimeStamp) / 1000000000.0, parallelismLevel);
    }
    this.dopPlotData.addSeries(plotData);
    this.parallelismHistogramDataSet = new DefaultCategoryDataset();

    double avgParallelism1 = 0.0;
    double avgParallelism2 = 0.0;
    long t = 0;

    for (int i = 1; i < histogramData.size(); ++i) {
        t += histogramData.get(i);
    }

    for (int i = 0; i < histogramData.size(); ++i) {
        parallelismHistogramDataSet.addValue((double) histogramData.get(i) / 1000000.0, "",
                i == 0 ? "Idle" : "" + i);
        avgParallelism1 += i * ((double) histogramData.get(i) / this.profilingData.applicationRunTime());
        avgParallelism2 += i * ((double) histogramData.get(i) / t);
    }

    final JFreeChart chart = ChartFactory.createBarChart("", "Parallelism", "ms",
            this.parallelismHistogramDataSet, PlotOrientation.VERTICAL, false, true, false);
    final ChartPanel chartPanel = new ChartPanel(chart);
    this.parallelismHistogramPanel.setLayout(new BorderLayout());
    this.parallelismHistogramPanel.add(chartPanel, BorderLayout.CENTER);

    this.runtimeTextField.setText("" + (this.profilingData.applicationRunTime() / 1000000.0));
    this.computationTimeMsTextField.setText("" + (this.profilingData.getOverallProcessingTime() / 1000000.0));
    this.computationTimePercentTextField.setText("" + (this.profilingData.getOverallProcessingTime() * 100.0
            / this.profilingData.applicationRunTime()));
    this.actorInstancesTextField.setText("" + this.actorInstances.size());
    this.messagesSentTextField.setText("" + this.profilingData.getMessagesSentCount());
    this.messagesSentPerSecondTextField.setText("" + ((double) this.profilingData.getMessagesSentCount()
            * 1000000000.0 / this.profilingData.applicationRunTime()));
    this.messagesProcessedTextField.setText("" + this.profilingData.getMessagesProcessedCount());
    this.messagesProcessedPerSecondTextField
            .setText("" + ((double) this.profilingData.getMessagesProcessedCount() * 1000000000.0
                    / this.profilingData.applicationRunTime()));
    this.averageTimeInMailboxTextField.setText("" + (this.profilingData.getAverageTimeInMailbox() / 1000000.0));
    this.avgParallelismWithIdleTimeTextField.setText("" + avgParallelism1);
    this.avgParallelismWithouIdleTimeTextField.setText("" + avgParallelism2);

    final SpawnTreeGraphScene spawnTreeGraphScene = new SpawnTreeGraphScene(this);
    this.spawnTreeScrollPane.setViewportView(spawnTreeGraphScene.createView());

    this.actorInstances.stream().forEach((actorInstance) -> {
        spawnTreeGraphScene.addNode(actorInstance);
    });
    for (final ActorInstance actorInstance : this.actorInstances) {
        if (actorInstance.supervisor != null) {
            final ImmutableTupel<ActorInstance, ActorInstance> edge = new ImmutableTupel(
                    actorInstance.supervisor, actorInstance);
            spawnTreeGraphScene.addEdge(edge);
            spawnTreeGraphScene.setEdgeSource(edge, actorInstance.supervisor);
            spawnTreeGraphScene.setEdgeTarget(edge, actorInstance);
        }
    }
}

From source file:org.apache.click.util.RequestTypeConverter.java

/**
 * Return the time value in milliseconds of the given date value string,
 * or Long.MIN_VALUE if the date could not be determined.
 *
 * @param value the date value string/* w  w  w. ja  v a  2s.  c o  m*/
 * @return the time value in milliseconds or Long.MIN_VALUE if not determined
 */
protected long getTimeFromDateString(String value) {
    Validate.notNull(value, "Null value string");

    value = value.trim();

    if (value.length() == 0) {
        return Long.MIN_VALUE;
    }

    if (isTimeValue(value)) {
        return Long.parseLong(value);
    }

    java.util.Date date = createDateFromSqlString(value);
    if (date != null) {
        return date.getTime();
    }

    try {
        DateFormat format = DateFormat.getDateInstance();

        date = format.parse(value);

        return date.getTime();

    } catch (ParseException pe) {
        return Long.MIN_VALUE;
    }
}