コード例 #1
0
ファイル: DocBuilder.java プロジェクト: ashishlal/echidna_2.0
  private void handleSpecialCommands(Map<String, Object> arow, DocWrapper doc) {
    Object value = arow.get("$deleteDocById");
    if (value != null) {
      if (value instanceof Collection) {
        Collection collection = (Collection) value;
        for (Object o : collection) {
          writer.deleteDoc(o.toString());
        }
      } else {
        writer.deleteDoc(value);
      }
    }
    value = arow.get("$deleteDocByQuery");
    if (value != null) {
      if (value instanceof Collection) {
        Collection collection = (Collection) value;
        for (Object o : collection) {
          writer.deleteByQuery(o.toString());
        }
      } else {
        writer.deleteByQuery(value.toString());
      }
    }
    value = arow.get("$docBoost");
    if (value != null) {
      float value1 = 1.0f;
      if (value instanceof Number) {
        value1 = ((Number) value).floatValue();
      } else {
        value1 = Float.parseFloat(value.toString());
      }
      doc.setDocumentBoost(value1);
    }

    value = arow.get("$skipDoc");
    if (value != null) {
      if (Boolean.parseBoolean(value.toString())) {
        throw new DataImportHandlerException(
            DataImportHandlerException.SKIP, "Document skipped :" + arow);
      }
    }

    value = arow.get("$skipRow");
    if (value != null) {
      if (Boolean.parseBoolean(value.toString())) {
        throw new DataImportHandlerException(DataImportHandlerException.SKIP_ROW);
      }
    }
  }
コード例 #2
0
 @Override
 public boolean isEventDuplicatedInCluster() {
   return Boolean.parseBoolean(
       eventAdapterConfiguration
           .getProperties()
           .get(EventAdapterConstants.EVENTS_DUPLICATED_IN_CLUSTER));
 }
コード例 #3
0
  public boolean tryToApplyActivationState(boolean active, Window window) {
    final Component frame = UIUtil.findUltimateParent(window);

    if (frame instanceof IdeFrame) {
      final IdeFrame ideFrame = (IdeFrame) frame;
      if (isActive() != active) {
        myActive = Boolean.valueOf(active);
        System.setProperty("idea.active", Boolean.valueOf(myActive).toString());
        if (active) {
          myDispatcher.getMulticaster().applicationActivated(ideFrame);
        } else {
          myDispatcher.getMulticaster().applicationDeactivated(ideFrame);
        }
        return true;
      }
    }

    return false;
  }
コード例 #4
0
  public boolean tryToApplyActivationState(boolean active, Window window) {
    final Component frame = UIUtil.findUltimateParent(window);

    if (frame instanceof IdeFrame) {
      final IdeFrame ideFrame = (IdeFrame) frame;
      if (isActive() != active) {
        myActive = Boolean.valueOf(active);
        System.setProperty("idea.active", myActive.toString());
        ApplicationActivationListener publisher =
            getMessageBus().syncPublisher(ApplicationActivationListener.TOPIC);
        if (active) {
          publisher.applicationActivated(ideFrame);
        } else {
          publisher.applicationDeactivated(ideFrame);
        }
        return true;
      }
    }

    return false;
  }
コード例 #5
0
  @Override
  public <T> boolean invokeConcurrentlyUnderProgress(
      @NotNull final List<T> things,
      ProgressIndicator progress,
      boolean runInReadAction,
      boolean failFastOnAcquireReadAction,
      @NotNull final Processor<? super T> thingProcessor)
      throws ProcessCanceledException {
    // supply our own indicator even if we haven't given one - to support cancellation
    final ProgressIndicator wrapper =
        progress == null
            ? new AbstractProgressIndicatorBase()
            : new SensitiveProgressWrapper(progress);

    Boolean result = processImmediatelyIfTooFew(things, wrapper, runInReadAction, thingProcessor);
    if (result != null) return result.booleanValue();

    ApplierCompleter<T> applier =
        new ApplierCompleter<>(
            null, runInReadAction, wrapper, things, thingProcessor, 0, things.size(), null);
    try {
      pool.invoke(applier);
      if (applier.throwable != null) throw applier.throwable;
    } catch (ApplierCompleter.ComputationAbortedException e) {
      return false;
    } catch (ProcessCanceledException e) {
      // task1.processor returns false and the task cancels the indicator
      // then task2 calls checkCancel() and get here
      return false;
    } catch (RuntimeException | Error e) {
      throw e;
    } catch (Throwable e) {
      throw new RuntimeException(e);
    }
    assert applier.isDone();
    return applier.completeTaskWhichFailToAcquireReadAction();
  }
コード例 #6
0
  private void registerDynamicEndpoint(String adapterName) {

    String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();

    String endpoint;
    if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
      endpoint = HTTPEventAdapterConstants.ENDPOINT_PREFIX + adapterName;
    } else {
      endpoint =
          HTTPEventAdapterConstants.ENDPOINT_PREFIX
              + HTTPEventAdapterConstants.ENDPOINT_TENANT_KEY
              + HTTPEventAdapterConstants.ENDPOINT_URL_SEPARATOR
              + tenantDomain
              + HTTPEventAdapterConstants.ENDPOINT_URL_SEPARATOR
              + adapterName;
    }

    try {
      String basicAuthEnabledValue =
          eventAdapterConfiguration
              .getProperties()
              .get(HTTPEventAdapterConstants.BASIC_AUTH_ENABLED);
      boolean isBasicAuthEnabled = true;
      if (basicAuthEnabledValue != null) {
        isBasicAuthEnabled = Boolean.parseBoolean(basicAuthEnabledValue);
      }
      HttpService httpService = HTTPEventAdapterServiceValueHolder.getHTTPService();
      if (httpService == null) {
        throw new InputEventAdapterRuntimeException(
            "HttpService not available, Error in registering endpoint " + endpoint);
      }
      httpService.registerServlet(
          endpoint,
          new HTTPMessageServlet(
              eventAdaptorListener,
              tenantId,
              eventAdapterConfiguration
                  .getProperties()
                  .get(HTTPEventAdapterConstants.EXPOSED_TRANSPORTS),
              isBasicAuthEnabled),
          new Hashtable(),
          httpService.createDefaultHttpContext());
    } catch (ServletException | NamespaceException e) {
      throw new InputEventAdapterRuntimeException("Error in registering endpoint " + endpoint, e);
    }
  }
コード例 #7
0
ファイル: DeviceProfile.java プロジェクト: pedrokiefer/ols
 /**
  * Returns whether or not the device supports a noise filter.
  *
  * @return <code>true</code> if a noise filter is present in the device, <code>false</code>
  *     otherwise.
  */
 public boolean isNoiseFilterSupported() {
   final String value = this.properties.get(DEVICE_FEATURE_NOISEFILTER);
   return Boolean.parseBoolean(value);
 }
コード例 #8
0
ファイル: DeviceProfile.java プロジェクト: pedrokiefer/ols
 /**
  * Returns whether or not the device supports triggers.
  *
  * @return <code>true</code> if the device supports triggers, <code>false</code> otherwise.
  */
 public boolean isTriggerSupported() {
   final String value = this.properties.get(DEVICE_FEATURE_TRIGGERS);
   return Boolean.parseBoolean(value);
 }
コード例 #9
0
ファイル: DeviceProfile.java プロジェクト: pedrokiefer/ols
 /**
  * Returns whether or not the device supports a testing mode.
  *
  * @return <code>true</code> if testing mode is supported by the device, <code>false</code>
  *     otherwise.
  */
 public boolean isTestModeSupported() {
   final String value = this.properties.get(DEVICE_FEATURE_TEST_MODE);
   return Boolean.parseBoolean(value);
 }
コード例 #10
0
ファイル: DeviceProfile.java プロジェクト: pedrokiefer/ols
 /**
  * Returns whether the device send its samples in "reverse" order.
  *
  * @return <code>true</code> if samples are send in reverse order (= last sample first), <code>
  *     false</code> otherwise.
  */
 public boolean isSamplesInReverseOrder() {
   final String rawValue = this.properties.get(DEVICE_SAMPLE_REVERSE_ORDER);
   return Boolean.parseBoolean(rawValue);
 }
コード例 #11
0
ファイル: DeviceProfile.java プロジェクト: pedrokiefer/ols
 /**
  * Returns whether or not the device supports RLE (Run-Length Encoding).
  *
  * @return <code>true</code> if a RLE encoder is present in the device, <code>false</code>
  *     otherwise.
  */
 public boolean isRleSupported() {
   final String value = this.properties.get(DEVICE_FEATURE_RLE);
   return Boolean.parseBoolean(value);
 }
コード例 #12
0
  /**
   * Returns boolean value from system property or provided function.
   *
   * @param propName System property host.
   * @param dflt Function that returns {@code Boolean}.
   * @return {@code Boolean} value
   */
  public static boolean boolValue(String propName, boolean dflt) {
    String sysProp = getProperty(propName);

    return (sysProp != null && !sysProp.isEmpty()) ? Boolean.getBoolean(sysProp) : dflt;
  }
コード例 #13
0
  public static void main(String[] args) throws Throwable {
    final int itrs = Integer.getInteger("iterations", 100000);
    // final int itrs = Integer.getInteger("iterations", 12);
    final int size = Integer.getInteger("size", 2048);
    final int subsize = Integer.getInteger("subsize", 128);
    final int maxchar = Integer.getInteger("maxchar", 128);
    final String regex = System.getProperty("filter");
    final Pattern filter = (regex == null) ? null : Pattern.compile(regex);
    final boolean useSecurityManager = Boolean.getBoolean("SecurityManager");
    if (useSecurityManager) System.setSecurityManager(new PermissiveSecurityManger());
    final Random rnd = new Random();

    String[] csns =
        new String[] {
          "Big5",
          "Johab",
          "EUC_CN",
          "EUC_KR",
          "MS932",
          "MS936",
          "MS949",
          "MS950",
          "GBK",
          "Big5_HKSCS",
          "Big5_HKSCS_2001",
          "Big5_Solaris",
          "MS950_HKSCS",
          "MS950_HKSCS_XP",
          "IBM1364",
          "IBM1381",
          "IBM1383",
          "IBM930",
          "IBM933",
          "IBM935",
          "IBM937",
          "IBM939",
          "IBM942",
          "IBM943",
          "IBM948",
          "IBM949",
          "IBM950",
          "IBM970",
        };

    ArrayList<long[]> sum = new ArrayList<>();

    for (final String csn : csns) {
      final Charset cs = Charset.forName(csn);
      List<Integer> cps = new ArrayList<>(0x4000);
      int off = 0;
      int cp = 0;
      int n = 0;
      CharsetEncoder enc = cs.newEncoder();
      while (cp < 0x10000 && n < cps.size()) {
        if (enc.canEncode((char) cp)) {
          cps.add(cp);
          n++;
        }
        cp++;
      }
      Collections.shuffle(cps);
      char[] ca = new char[cps.size()];
      for (int i = 0; i < cps.size(); i++) ca[i] = (char) (int) cps.get(i);

      System.out.printf("%n--------%s---------%n", csn);
      for (int sz = 8; sz <= 2048; sz *= 2) {
        System.out.printf("   [len=%d]%n", sz);

        final char[] chars = Arrays.copyOf(ca, sz);
        final String str = new String(chars);
        final byte[] bs = str.getBytes(cs);

        Job[] jobs = {
          new Job("String decode: csn") {
            public void work() throws Throwable {
              for (int i = 0; i < itrs; i++) new String(bs, csn);
            }
          },
          new Job("String decode: cs") {
            public void work() throws Throwable {
              for (int i = 0; i < itrs; i++) new String(bs, cs);
            }
          },
          new Job("String encode: csn") {
            public void work() throws Throwable {
              for (int i = 0; i < itrs; i++) str.getBytes(csn);
            }
          },
          new Job("String encode: cs") {
            public void work() throws Throwable {
              for (int i = 0; i < itrs; i++) str.getBytes(cs);
            }
          },
        };
        sum.add(time(jobs));
      }
    }
  }
コード例 #14
0
ファイル: DeviceProfile.java プロジェクト: pedrokiefer/ols
 /**
  * Returns whether or not the device supports "double-data rate" sampling, also known as
  * "demux"-sampling.
  *
  * @return <code>true</code> if DDR is supported by the device, <code>false</code> otherwise.
  */
 public boolean isDoubleDataRateSupported() {
   final String value = this.properties.get(DEVICE_SUPPORTS_DDR);
   return Boolean.parseBoolean(value);
 }
コード例 #15
0
ファイル: DeviceProfile.java プロジェクト: pedrokiefer/ols
 /**
  * Returns whether or not the device supports "complex" triggers.
  *
  * @return <code>true</code> if complex triggers are supported by the device, <code>false</code>
  *     otherwise.
  */
 public boolean isComplexTriggersSupported() {
   final String value = this.properties.get(DEVICE_TRIGGER_COMPLEX);
   return Boolean.parseBoolean(value);
 }
コード例 #16
0
ファイル: DeviceProfile.java プロジェクト: pedrokiefer/ols
 /**
  * Returns whether or not the capture size is bound to the number of channels.
  *
  * @return <code>true</code> if the capture size is bound to the number of channels, <code>false
  *     </code> otherwise.
  */
 public boolean isCaptureSizeBoundToEnabledChannels() {
   final String value = this.properties.get(DEVICE_CAPTURESIZE_BOUND);
   return Boolean.parseBoolean(value);
 }
コード例 #17
0
ファイル: TestApp.java プロジェクト: karanbatra/hazelcast
  protected void handleCommand(String command) {
    if (command.contains("__")) {
      namespace = command.split("__")[0];
      command = command.substring(command.indexOf("__") + 2);
    }

    if (echo) {
      if (Thread.currentThread().getName().toLowerCase().indexOf("main") < 0)
        println(" [" + Thread.currentThread().getName() + "] " + command);
      else println(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 * 1000 / (Clock.currentTimeMillis() - t0));
      return;
    } 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 < 4) {
                    command += " " + Integer.parseInt(threadArgs[1]) * threadID;
                  }
                }
                handleCommand(command);
              }
            });
      }
      pool.shutdown();
      try {
        pool.awaitTermination(60 * 60, TimeUnit.SECONDS); // wait 1h
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else if (first.startsWith("@")) {
      if (first.length() == 1) {
        println("usage: @<file-name>");
        return;
      }
      File f = new File(first.substring(1));
      println("Executing script file " + f.getAbsolutePath());
      if (f.exists()) {
        try {
          BufferedReader br = new BufferedReader(new FileReader(f));
          String l = br.readLine();
          while (l != null) {
            handleCommand(l);
            l = br.readLine();
          }
          br.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      } else {
        println("File not found! " + f.getAbsolutePath());
      }
    } else if (command.indexOf(';') != -1) {
      StringTokenizer st = new StringTokenizer(command, ";");
      while (st.hasMoreTokens()) {
        handleCommand(st.nextToken());
      }
      return;
    } 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)) {
      if (args.length > 1) {
        namespace = args[1];
        println("namespace: " + namespace);
        //                init();
      }
    } else if ("whoami".equals(first)) {
      println(hazelcast.getCluster().getLocalMember());
    } else if ("who".equals(first)) {
      println(hazelcast.getCluster());
    } else if ("jvm".equals(first)) {
      System.gc();
      println("Memory max: " + Runtime.getRuntime().maxMemory() / 1024 / 1024 + "M");
      println(
          "Memory free: "
              + Runtime.getRuntime().freeMemory() / 1024 / 1024
              + "M "
              + (int) (Runtime.getRuntime().freeMemory() * 100 / Runtime.getRuntime().maxMemory())
              + "%");
      long total = Runtime.getRuntime().totalMemory();
      long free = Runtime.getRuntime().freeMemory();
      println("Used Memory:" + ((total - free) / 1024 / 1024) + "MB");
      println("# procs: " + Runtime.getRuntime().availableProcessors());
      println(
          "OS info: "
              + ManagementFactory.getOperatingSystemMXBean().getArch()
              + " "
              + ManagementFactory.getOperatingSystemMXBean().getName()
              + " "
              + ManagementFactory.getOperatingSystemMXBean().getVersion());
      println(
          "JVM: "
              + ManagementFactory.getRuntimeMXBean().getVmVendor()
              + " "
              + ManagementFactory.getRuntimeMXBean().getVmName()
              + " "
              + ManagementFactory.getRuntimeMXBean().getVmVersion());
    } else if (first.indexOf("ock") != -1 && first.indexOf(".") == -1) {
      handleLock(args);
    } else if (first.indexOf(".size") != -1) {
      handleSize(args);
    } else if (first.indexOf(".clear") != -1) {
      handleClear(args);
    } else if (first.indexOf(".destroy") != -1) {
      handleDestroy(args);
    } else if (first.indexOf(".iterator") != -1) {
      handleIterator(args);
    } else if (first.indexOf(".contains") != -1) {
      handleContains(args);
    } else if (first.indexOf(".stats") != -1) {
      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.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.indexOf(".addListener") != -1) {
      handleAddListener(args);
    } else if (first.equals("m.removeMapListener")) {
      handleRemoveListener(args);
    } else if (first.equals("m.unlock")) {
      handleMapUnlock(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 {
      println("type 'help' for help");
    }
  }
コード例 #18
0
  public MessageHandler() {
    this.asyncEventExecution =
        Boolean.parseBoolean(
            (String)
                Comet.getServer()
                    .getConfig()
                    .getOrDefault("comet.network.alternativePacketHandling.enabled", "false"));
    //        this.eventExecutor = asyncEventExecution ?
    // Executors.newFixedThreadPool(Integer.parseInt((String)
    // Comet.getServer().getConfig().getOrDefault("comet.network.alternativePacketHandling.threads",
    // "8"))) : null;

    if (this.asyncEventExecution) {
      switch ((String)
          Comet.getServer()
              .getConfig()
              .getOrDefault("comet.network.alternativePacketHandling.type", "threadpool")) {
        default:
          log.info("Using thread-pool event executor");
          this.eventExecutor =
              new ThreadPoolExecutor(
                  Integer.parseInt(
                      (String)
                          Comet.getServer()
                              .getConfig()
                              .getOrDefault(
                                  "comet.network.alternativePacketHandling.coreSize",
                                  "8")), // core size
                  Integer.parseInt(
                      (String)
                          Comet.getServer()
                              .getConfig()
                              .getOrDefault(
                                  "comet.network.alternativePacketHandling.maxSize",
                                  "32")), // max size
                  10 * 60, // idle timeout
                  TimeUnit.SECONDS,
                  new LinkedBlockingQueue<>());
          break;

        case "forkjoin":
          log.info("Using fork-join event executor");
          this.eventExecutor =
              new ForkJoinPool(
                  Integer.parseInt(
                      (String)
                          Comet.getServer()
                              .getConfig()
                              .getOrDefault(
                                  "comet.network.alternativePacketHandling.coreSize", 16)),
                  ForkJoinPool.defaultForkJoinWorkerThreadFactory,
                  null,
                  true);
          break;
      }
    } else {
      this.eventExecutor = null;
    }

    this.load();
  }
コード例 #19
0
ファイル: DeviceProfile.java プロジェクト: pedrokiefer/ols
 /**
  * Returns whether upon opening the DTR line needs to be high (= <code>true</code>) or low (=
  * <code>false</code>).
  *
  * <p>This method has no meaning if the used interface is <em>not</em> {@link
  * DeviceInterface#SERIAL}.
  *
  * @return <code>true</code> if the DTR line needs to be set upon opening the serial port, <code>
  *     false</code> if the DTR line needs to be reset upon opening the serial port.
  */
 public boolean isOpenPortDtr() {
   final String value = this.properties.get(DEVICE_OPEN_PORT_DTR);
   return Boolean.parseBoolean(value);
 }
コード例 #20
0
  /**
   * Load client configuration from the properties map.
   *
   * @param prefix Prefix for the client properties.
   * @param in Properties map to load configuration from.
   * @throws GridClientException If parsing configuration failed.
   */
  public void load(String prefix, Properties in) throws GridClientException {
    while (prefix.endsWith(".")) prefix = prefix.substring(0, prefix.length() - 1);

    if (!prefix.isEmpty()) prefix += ".";

    String balancer = in.getProperty(prefix + "balancer");
    String connectTimeout = in.getProperty(prefix + "connectTimeout");
    String cred = in.getProperty(prefix + "credentials");
    String autoFetchMetrics = in.getProperty(prefix + "autoFetchMetrics");
    String autoFetchAttrs = in.getProperty(prefix + "autoFetchAttributes");
    String maxConnIdleTime = in.getProperty(prefix + "idleTimeout");
    String proto = in.getProperty(prefix + "protocol");
    String srvrs = in.getProperty(prefix + "servers");
    String tcpNoDelay = in.getProperty(prefix + "tcp.noDelay");
    String topRefreshFreq = in.getProperty(prefix + "topology.refresh");

    String sslEnabled = in.getProperty(prefix + "ssl.enabled");

    String sslProto = in.getProperty(prefix + "ssl.protocol", "TLS");
    String sslKeyAlg = in.getProperty(prefix + "ssl.key.algorithm", "SunX509");

    String keyStorePath = in.getProperty(prefix + "ssl.keystore.location");
    String keyStorePwd = in.getProperty(prefix + "ssl.keystore.password");
    String keyStoreType = in.getProperty(prefix + "ssl.keystore.type");

    String trustStorePath = in.getProperty(prefix + "ssl.truststore.location");
    String trustStorePwd = in.getProperty(prefix + "ssl.truststore.password");
    String trustStoreType = in.getProperty(prefix + "ssl.truststore.type");

    String dataCfgs = in.getProperty(prefix + "data.configurations");

    setBalancer(resolveBalancer(balancer));

    if (!F.isEmpty(connectTimeout)) setConnectTimeout(Integer.parseInt(connectTimeout));

    if (!F.isEmpty(cred)) {
      int idx = cred.indexOf(':');

      if (idx >= 0 && idx < cred.length() - 1) {
        setSecurityCredentialsProvider(
            new SecurityCredentialsBasicProvider(
                new SecurityCredentials(cred.substring(0, idx), cred.substring(idx + 1))));
      } else {
        setSecurityCredentialsProvider(
            new SecurityCredentialsBasicProvider(new SecurityCredentials(null, null, cred)));
      }
    }

    if (!F.isEmpty(autoFetchMetrics)) setAutoFetchMetrics(Boolean.parseBoolean(autoFetchMetrics));

    if (!F.isEmpty(autoFetchAttrs)) setAutoFetchAttributes(Boolean.parseBoolean(autoFetchAttrs));

    if (!F.isEmpty(maxConnIdleTime)) setMaxConnectionIdleTime(Integer.parseInt(maxConnIdleTime));

    if (!F.isEmpty(proto)) setProtocol(GridClientProtocol.valueOf(proto));

    if (!F.isEmpty(srvrs)) setServers(Arrays.asList(srvrs.replaceAll("\\s+", "").split(",")));

    if (!F.isEmpty(tcpNoDelay)) setTcpNoDelay(Boolean.parseBoolean(tcpNoDelay));

    if (!F.isEmpty(topRefreshFreq)) setTopologyRefreshFrequency(Long.parseLong(topRefreshFreq));

    //
    // SSL configuration section
    //

    if (!F.isEmpty(sslEnabled) && Boolean.parseBoolean(sslEnabled)) {
      GridSslBasicContextFactory factory = new GridSslBasicContextFactory();

      factory.setProtocol(F.isEmpty(sslProto) ? "TLS" : sslProto);
      factory.setKeyAlgorithm(F.isEmpty(sslKeyAlg) ? "SunX509" : sslKeyAlg);

      if (F.isEmpty(keyStorePath))
        throw new IllegalArgumentException("SSL key store location is not specified.");

      factory.setKeyStoreFilePath(keyStorePath);

      if (keyStorePwd != null) factory.setKeyStorePassword(keyStorePwd.toCharArray());

      factory.setKeyStoreType(F.isEmpty(keyStoreType) ? "jks" : keyStoreType);

      if (F.isEmpty(trustStorePath))
        factory.setTrustManagers(GridSslBasicContextFactory.getDisabledTrustManager());
      else {
        factory.setTrustStoreFilePath(trustStorePath);

        if (trustStorePwd != null) factory.setTrustStorePassword(trustStorePwd.toCharArray());

        factory.setTrustStoreType(F.isEmpty(trustStoreType) ? "jks" : trustStoreType);
      }

      setSslContextFactory(factory);
    }

    //
    // Data configuration section
    //

    if (!F.isEmpty(dataCfgs)) {
      String[] names = dataCfgs.replaceAll("\\s+", "").split(",");
      Collection<GridClientDataConfiguration> list = new ArrayList<>();

      for (String cfgName : names) {
        if (F.isEmpty(cfgName)) continue;

        String name = in.getProperty(prefix + "data." + cfgName + ".name");
        String bal = in.getProperty(prefix + "data." + cfgName + ".balancer");
        String aff = in.getProperty(prefix + "data." + cfgName + ".affinity");

        GridClientDataConfiguration dataCfg = new GridClientDataConfiguration();

        dataCfg.setName(F.isEmpty(name) ? null : name);
        dataCfg.setBalancer(resolveBalancer(bal));
        dataCfg.setAffinity(resolveAffinity(aff));

        list.add(dataCfg);
      }

      setDataConfigurations(list);
    }
  }