Search in sources :

Example 11 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project hazelcast by hazelcast.

the class ClientConsoleApp method handleCommand.

//CHECKSTYLE:OFF
/**
     * Handle a command
     *
     * @param commandInputted
     */
@SuppressFBWarnings("DM_EXIT")
protected void handleCommand(String commandInputted) {
    String command = commandInputted;
    if (command == null) {
        return;
    }
    if (command.contains("__")) {
        namespace = command.split("__")[0];
        command = command.substring(command.indexOf("__") + 2);
    }
    if (echo) {
        handleEcho(command);
    }
    if (command == null || command.startsWith("//")) {
        return;
    }
    command = command.trim();
    if (command == null || command.length() == 0) {
        return;
    }
    String first = command;
    int spaceIndex = command.indexOf(' ');
    String[] argsSplit = command.split(" ");
    String[] args = new String[argsSplit.length];
    for (int i = 0; i < argsSplit.length; i++) {
        args[i] = argsSplit[i].trim();
    }
    if (spaceIndex != -1) {
        first = args[0];
    }
    if (command.startsWith("help")) {
        handleHelp(command);
    } else if (first.startsWith("#") && first.length() > 1) {
        int repeat = Integer.parseInt(first.substring(1));
        long t0 = Clock.currentTimeMillis();
        for (int i = 0; i < repeat; i++) {
            handleCommand(command.substring(first.length()).replaceAll("\\$i", "" + i));
        }
        println("ops/s = " + repeat * ONE_THOUSAND / (Clock.currentTimeMillis() - t0));
    } else if (first.startsWith("&") && first.length() > 1) {
        final int fork = Integer.parseInt(first.substring(1));
        ExecutorService pool = Executors.newFixedThreadPool(fork);
        final String threadCommand = command.substring(first.length());
        for (int i = 0; i < fork; i++) {
            final int threadID = i;
            pool.submit(new Runnable() {

                public void run() {
                    String command = threadCommand;
                    String[] threadArgs = command.replaceAll("\\$t", "" + threadID).trim().split(" ");
                    // TODO &t #4 m.putmany x k
                    if ("m.putmany".equals(threadArgs[0]) || "m.removemany".equals(threadArgs[0])) {
                        if (threadArgs.length < LENGTH_BORDER) {
                            command += " " + Integer.parseInt(threadArgs[1]) * threadID;
                        }
                    }
                    handleCommand(command);
                }
            });
        }
        pool.shutdown();
        try {
            // wait 1h
            pool.awaitTermination(ONE_HOUR, TimeUnit.SECONDS);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (first.startsWith("@")) {
        handleAt(first);
    } else if (command.indexOf(';') != -1) {
        handleColon(command);
    } else if ("silent".equals(first)) {
        silent = Boolean.parseBoolean(args[1]);
    } else if ("shutdown".equals(first)) {
        hazelcast.getLifecycleService().shutdown();
    } else if ("echo".equals(first)) {
        echo = Boolean.parseBoolean(args[1]);
        println("echo: " + echo);
    } else if ("ns".equals(first)) {
        handleNamespace(args);
    } else if ("whoami".equals(first)) {
        handleWhoami();
    } else if ("who".equals(first)) {
        handleWho();
    } else if ("jvm".equals(first)) {
        handleJvm();
    } else if (first.contains("ock") && !first.contains(".")) {
        handleLock(args);
    } else if (first.contains(".size")) {
        handleSize(args);
    } else if (first.contains(".clear")) {
        handleClear(args);
    } else if (first.contains(".destroy")) {
        handleDestroy(args);
    } else if (first.contains(".iterator")) {
        handleIterator(args);
    } else if (first.contains(".contains")) {
        handleContains(args);
    } else if (first.contains(".stats")) {
        handStats(args);
    } else if ("t.publish".equals(first)) {
        handleTopicPublish(args);
    } else if ("q.offer".equals(first)) {
        handleQOffer(args);
    } else if ("q.take".equals(first)) {
        handleQTake(args);
    } else if ("q.poll".equals(first)) {
        handleQPoll(args);
    } else if ("q.peek".equals(first)) {
        handleQPeek(args);
    } else if ("q.capacity".equals(first)) {
        handleQCapacity(args);
    } else if ("q.offermany".equals(first)) {
        handleQOfferMany(args);
    } else if ("q.pollmany".equals(first)) {
        handleQPollMany(args);
    } else if ("s.add".equals(first)) {
        handleSetAdd(args);
    } else if ("s.remove".equals(first)) {
        handleSetRemove(args);
    } else if ("s.addmany".equals(first)) {
        handleSetAddMany(args);
    } else if ("s.removemany".equals(first)) {
        handleSetRemoveMany(args);
    } else if (first.equals("m.replace")) {
        handleMapReplace(args);
    } else if (first.equalsIgnoreCase("m.putIfAbsent")) {
        handleMapPutIfAbsent(args);
    } else if (first.equals("m.putAsync")) {
        handleMapPutAsync(args);
    } else if (first.equals("m.getAsync")) {
        handleMapGetAsync(args);
    } else if (first.equals("m.put")) {
        handleMapPut(args);
    } else if (first.equals("m.get")) {
        handleMapGet(args);
    } else if (first.equalsIgnoreCase("m.getMapEntry")) {
        handleMapGetMapEntry(args);
    } else if (first.equals("m.remove")) {
        handleMapRemove(args);
    } else if (first.equals("m.evict")) {
        handleMapEvict(args);
    } else if (first.equals("m.putmany") || first.equalsIgnoreCase("m.putAll")) {
        handleMapPutMany(args);
    } else if (first.equals("m.getmany")) {
        handleMapGetMany(args);
    } else if (first.equals("m.removemany")) {
        handleMapRemoveMany(args);
    } else if (command.equalsIgnoreCase("m.localKeys")) {
        handleMapLocalKeys();
    } else if (command.equalsIgnoreCase("m.localSize")) {
        handleMapLocalSize();
    } else if (command.equals("m.keys")) {
        handleMapKeys();
    } else if (command.equals("m.values")) {
        handleMapValues();
    } else if (command.equals("m.entries")) {
        handleMapEntries();
    } else if (first.equals("m.lock")) {
        handleMapLock(args);
    } else if (first.equalsIgnoreCase("m.tryLock")) {
        handleMapTryLock(args);
    } else if (first.equals("m.unlock")) {
        handleMapUnlock(args);
    } else if (first.contains(".addListener")) {
        handleAddListener(args);
    } else if (first.equals("m.removeMapListener")) {
        handleRemoveListener(args);
    } else if (first.equals("m.unlock")) {
        handleMapUnlock(args);
    } else if (first.equals("mm.put")) {
        handleMultiMapPut(args);
    } else if (first.equals("mm.get")) {
        handleMultiMapGet(args);
    } else if (first.equals("mm.remove")) {
        handleMultiMapRemove(args);
    } else if (command.equals("mm.keys")) {
        handleMultiMapKeys();
    } else if (command.equals("mm.values")) {
        handleMultiMapValues();
    } else if (command.equals("mm.entries")) {
        handleMultiMapEntries();
    } else if (first.equals("mm.lock")) {
        handleMultiMapLock(args);
    } else if (first.equalsIgnoreCase("mm.tryLock")) {
        handleMultiMapTryLock(args);
    } else if (first.equals("mm.unlock")) {
        handleMultiMapUnlock(args);
    } else if (first.equals("l.add")) {
        handleListAdd(args);
    } else if (first.equals("l.set")) {
        handleListSet(args);
    } else if ("l.addmany".equals(first)) {
        handleListAddMany(args);
    } else if (first.equals("l.remove")) {
        handleListRemove(args);
    } else if (first.equals("l.contains")) {
        handleListContains(args);
    } else if ("a.get".equals(first)) {
        handleAtomicNumberGet(args);
    } else if ("a.set".equals(first)) {
        handleAtomicNumberSet(args);
    } else if ("a.inc".equals(first)) {
        handleAtomicNumberInc(args);
    } else if ("a.dec".equals(first)) {
        handleAtomicNumberDec(args);
    } else if (first.equals("execute")) {
        execute(args);
    } else if (first.equals("partitions")) {
        handlePartitions(args);
    //        } else if (first.equals("txn")) {
    //            hazelcast.getTransaction().begin();
    //        } else if (first.equals("commit")) {
    //            hazelcast.getTransaction().commit();
    //        } else if (first.equals("rollback")) {
    //            hazelcast.getTransaction().rollback();
    } else if (first.equalsIgnoreCase("executeOnKey")) {
        executeOnKey(args);
    } else if (first.equalsIgnoreCase("executeOnMember")) {
        executeOnMember(args);
    } else if (first.equalsIgnoreCase("executeOnMembers")) {
        executeOnMembers(args);
    // } else if (first.equalsIgnoreCase("longOther") || first.equalsIgnoreCase("executeLongOther")) {
    //     executeLongTaskOnOtherMember(args);
    //} else if (first.equalsIgnoreCase("long") || first.equalsIgnoreCase("executeLong")) {
    //    executeLong(args);
    } else if (first.equalsIgnoreCase("instances")) {
        handleInstances(args);
    } else if (first.equalsIgnoreCase("quit") || first.equalsIgnoreCase("exit")) {
        System.exit(0);
    } else if (first.startsWith("e") && first.endsWith(".simulateLoad")) {
        handleExecutorSimulate(args);
    } else {
        println("type 'help' for help");
    }
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) IExecutorService(com.hazelcast.core.IExecutorService) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 12 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project hazelcast by hazelcast.

the class ClusterServiceImpl method dispatchEvent.

@SuppressFBWarnings("BC_UNCONFIRMED_CAST")
@Override
public void dispatchEvent(MembershipEvent event, MembershipListener listener) {
    switch(event.getEventType()) {
        case MembershipEvent.MEMBER_ADDED:
            listener.memberAdded(event);
            break;
        case MembershipEvent.MEMBER_REMOVED:
            listener.memberRemoved(event);
            break;
        case MembershipEvent.MEMBER_ATTRIBUTE_CHANGED:
            MemberAttributeEvent memberAttributeEvent = (MemberAttributeEvent) event;
            listener.memberAttributeChanged(memberAttributeEvent);
            break;
        default:
            throw new IllegalArgumentException("Unhandled event: " + event);
    }
}
Also used : MemberAttributeEvent(com.hazelcast.core.MemberAttributeEvent) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 13 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project hazelcast by hazelcast.

the class RunGcRequest method writeResponse.

@Override
@SuppressFBWarnings(value = "DM_GC", justification = "Explicit GC is the point of this class")
public void writeResponse(ManagementCenterService mcs, JsonObject root) throws Exception {
    System.gc();
    root.add("result", new JsonObject());
}
Also used : JsonObject(com.eclipsesource.json.JsonObject) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 14 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project Gaffer by gchq.

the class StatusDeserialiser method deserialize.

@SuppressFBWarnings("DM_CONVERT_CASE")
@Override
public Status deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final ObjectCodec codec = jsonParser.getCodec();
    final JsonNode node = codec.readTree(jsonParser);
    final String statusStr = node.asText().toUpperCase().replace(' ', '_');
    return Status.valueOf(statusStr);
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectCodec(com.fasterxml.jackson.core.ObjectCodec) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 15 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project Gaffer by gchq.

the class AbstractCoreKeyRangeFactory method getRange.

@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "If an element is not an Entity it must be an Edge")
@Override
public <T extends GetElementsOperation<?, ?>> List<Range> getRange(final ElementSeed elementSeed, final T operation) throws RangeFactoryException {
    if (elementSeed instanceof EntitySeed) {
        if (SeedMatchingType.EQUAL.equals(operation.getSeedMatching()) && !operation.isIncludeEntities()) {
            throw new IllegalArgumentException("When doing querying by ID, you should only provide an EntitySeed seed if you also set includeEntities flag to true");
        }
        return getRange(((EntitySeed) elementSeed).getVertex(), operation, operation.getIncludeEdges());
    } else {
        if (!operation.isIncludeEntities() && IncludeEdgeType.NONE == operation.getIncludeEdges()) {
            throw new IllegalArgumentException("Need to get either Entities and/or Edges when getting Elements");
        }
        final EdgeSeed edgeSeed = (EdgeSeed) elementSeed;
        final List<Range> ranges = new ArrayList<>();
        if (IncludeEdgeType.ALL == operation.getIncludeEdges() || (IncludeEdgeType.DIRECTED == operation.getIncludeEdges() && edgeSeed.isDirected()) || (IncludeEdgeType.UNDIRECTED == operation.getIncludeEdges() && !edgeSeed.isDirected())) {
            // Get Edges with the given EdgeSeed - This is applicable for
            // EQUALS and RELATED seed matching.
            ranges.add(new Range(getKeyFromEdgeSeed(edgeSeed, operation, false), true, getKeyFromEdgeSeed(edgeSeed, operation, true), true));
        }
        if (SeedMatchingType.RELATED.equals(operation.getSeedMatching()) && operation.isIncludeEntities()) {
            // Get Entities related to EdgeSeeds
            ranges.addAll(getRange(edgeSeed.getSource(), operation, IncludeEdgeType.NONE));
            ranges.addAll(getRange(edgeSeed.getDestination(), operation, IncludeEdgeType.NONE));
        }
        return ranges;
    }
}
Also used : EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ArrayList(java.util.ArrayList) Range(org.apache.accumulo.core.data.Range) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)142 IOException (java.io.IOException)23 File (java.io.File)22 ArrayList (java.util.ArrayList)20 JPanel (javax.swing.JPanel)14 RollingStock (jmri.jmrit.operations.rollingstock.RollingStock)13 ScriptException (org.jaggeryjs.scriptengine.exceptions.ScriptException)13 FlowLayout (java.awt.FlowLayout)8 BoxLayout (javax.swing.BoxLayout)7 Location (jmri.jmrit.operations.locations.Location)7 Dimension (java.awt.Dimension)5 FileOutputStream (java.io.FileOutputStream)5 Connection (java.sql.Connection)5 PreparedStatement (java.sql.PreparedStatement)5 Iterator (java.util.Iterator)5 JScrollPane (javax.swing.JScrollPane)5 RouteLocation (jmri.jmrit.operations.routes.RouteLocation)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 List (java.util.List)4 Entry (java.util.Map.Entry)4