Esempio n. 1
0
  /**
   * ** Construct a new XmlEntity while creating Xml from the cache using the element which has
   * attributes matching those given
   *
   * @param parentType Parent type of the XML element to search for. Should be one of the constants
   *     from the {@link CacheXml} class. For example, CacheXml.REGION.
   * @param parentKey Identifier for the parent elements such "name/id"
   * @param parentValue Value of the identifier
   * @param childType Child type of the XML element to search for within the parent . Should be one
   *     of the constants from the {@link CacheXml} class. For example, CacheXml.INDEX.
   * @param childKey Identifier for the child element such as "name/id"
   * @param childValue Value of the child element identifier
   */
  public XmlEntity(
      final String parentType,
      final String parentKey,
      final String parentValue,
      final String childType,
      final String childKey,
      final String childValue) {
    // TODO this should be replaced with a builder.
    // TODO consider parent as nested XmlEntity type.
    this.parentType = parentType;
    this.type = childType;

    StringBuffer sb = new StringBuffer();
    sb.append("//").append(prefix).append(':').append(parentType);

    if (!StringUtils.isBlank(parentKey) && !StringUtils.isBlank(parentValue)) {
      sb.append("[@").append(parentKey).append("='").append(parentValue).append("']");
    }

    sb.append("/").append(prefix).append(':').append(childType);

    if (!StringUtils.isBlank(childKey) && !StringUtils.isBlank(childValue)) {
      sb.append("[@").append(childKey).append("='").append(childValue).append("']");
    }
    this.searchString = sb.toString();

    // no init();
  }
  @RequestMapping(
      method = RequestMethod.POST,
      value = "/durable-clients/{durable-client-id}/cqs/{durable-cq-name}",
      params = "op=close")
  @ResponseBody
  public String closeDurableContinuousQuery(
      @PathVariable("durable-client-id") final String durableClientId,
      @PathVariable("durable-cq-name") final String durableCqName,
      @RequestParam(value = CliStrings.CLOSE_DURABLE_CQS__MEMBER, required = false)
          final String memberNameId,
      @RequestParam(value = CliStrings.CLOSE_DURABLE_CQS__GROUP, required = false)
          final String[] groups) {
    final CommandStringBuilder command = new CommandStringBuilder(CliStrings.CLOSE_DURABLE_CQS);

    command.addOption(CliStrings.CLOSE_DURABLE_CQS__DURABLE__CLIENT__ID, decode(durableClientId));
    command.addOption(CliStrings.CLOSE_DURABLE_CQS__NAME, decode(durableCqName));

    if (hasValue(memberNameId)) {
      command.addOption(CliStrings.CLOSE_DURABLE_CQS__MEMBER, memberNameId);
    }

    if (hasValue(groups)) {
      command.addOption(
          CliStrings.CLOSE_DURABLE_CQS__GROUP,
          StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
    }

    return processCommand(command.toString());
  }
  protected String internalCountDurableClientContinuousQueryEvents(
      final String durableClientId,
      final String cqName,
      final String memberNameId,
      final String[] groups) {
    final CommandStringBuilder command =
        new CommandStringBuilder(CliStrings.COUNT_DURABLE_CQ_EVENTS);

    command.addOption(CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CLIENT__ID, durableClientId);

    if (hasValue(cqName)) {
      command.addOption(CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CQ__NAME, cqName);
    }

    if (hasValue(memberNameId)) {
      command.addOption(CliStrings.COUNT_DURABLE_CQ_EVENTS__MEMBER, memberNameId);
    }

    if (hasValue(groups)) {
      command.addOption(
          CliStrings.COUNT_DURABLE_CQ_EVENTS__GROUP,
          StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
    }

    return processCommand(command.toString());
  }
Esempio n. 4
0
  /**
   * 删除制定索引
   *
   * @param indexName
   */
  @Transactional
  public void deleteIndex(String indexName) {
    if (StringUtils.isBlank(indexName)) return;

    GmIndex index = dao.getByIndexName(indexName);
    if (index != null) dao.delete(index);
  }
  @Override
  public void execute(FunctionContext context) {
    InternalLocator locator = InternalLocator.getLocator();
    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
    DistributedMember member = cache.getDistributedSystem().getDistributedMember();
    SharedConfigurationStatus status = locator.getSharedConfigurationStatus().getStatus();

    String memberId = member.getName();
    if (StringUtils.isBlank(memberId)) {
      memberId = member.getId();
    }

    CliFunctionResult result = new CliFunctionResult(memberId, new String[] {status.name()});
    context.getResultSender().lastResult(result);
  }
Esempio n. 6
0
  private static String getWebAppBaseDirectory(final String context) {
    String underscoredContext = context.replace("/", "_");
    final String workingDirectory =
        USER_DIR
            .concat(FILE_PATH_SEPARATOR)
            .concat("GemFire_" + USER_NAME)
            .concat(FILE_PATH_SEPARATOR)
            .concat("services")
            .concat(FILE_PATH_SEPARATOR)
            .concat("http")
            .concat(FILE_PATH_SEPARATOR)
            .concat((StringUtils.isBlank(bindAddress)) ? "0.0.0.0" : bindAddress)
            .concat("_")
            .concat(String.valueOf(port).concat(underscoredContext));

    return workingDirectory;
  }
  @RequestMapping(method = RequestMethod.GET, value = "/durable-clients/{durable-client-id}/cqs")
  @ResponseBody
  public String listDurableClientContinuousQueries(
      @PathVariable("durable-client-id") final String durableClientId,
      @RequestParam(value = CliStrings.LIST_DURABLE_CQS__MEMBER, required = false)
          final String memberNameId,
      @RequestParam(value = CliStrings.LIST_DURABLE_CQS__GROUP, required = false)
          final String[] groups) {
    final CommandStringBuilder command = new CommandStringBuilder(CliStrings.LIST_DURABLE_CQS);

    command.addOption(CliStrings.LIST_DURABLE_CQS__DURABLECLIENTID, decode(durableClientId));

    if (hasValue(memberNameId)) {
      command.addOption(CliStrings.LIST_DURABLE_CQS__MEMBER, memberNameId);
    }

    if (hasValue(groups)) {
      command.addOption(
          CliStrings.LIST_DURABLE_CQS__GROUP,
          StringUtils.concat(groups, StringUtils.COMMA_DELIMITER));
    }

    return processCommand(command.toString());
  }
Esempio n. 8
0
  private boolean checkIndexValueValid(String indexName, String clause) {
    if (StringUtils.isBlank(indexName) || StringUtils.isBlank(clause)) return false;

    return true;
  }
Esempio n. 9
0
  public static Server initJetty(
      final String bindAddress,
      final int port,
      boolean useSSL,
      boolean needClientAuth,
      String protocols,
      String ciphers,
      Properties sysProps)
      throws Exception {

    final Server jettyServer = new Server();

    // Add a handler collection here, so that each new context adds itself
    // to this collection.
    jettyServer.setHandler(new HandlerCollection());
    ServerConnector connector = null;

    HttpConfiguration httpConfig = new HttpConfiguration();
    httpConfig.setSecureScheme(HTTPS);
    httpConfig.setSecurePort(port);

    if (useSSL) {
      SslContextFactory sslContextFactory = new SslContextFactory();

      sslContextFactory.setNeedClientAuth(needClientAuth);

      if (!StringUtils.isBlank(ciphers) && !"any".equalsIgnoreCase(ciphers)) {
        // If use has mentioned "any" let the SSL layer decide on the ciphers
        sslContextFactory.setIncludeCipherSuites(SSLUtil.readArray(ciphers));
      }

      String protocol = SSLUtil.getSSLAlgo(SSLUtil.readArray(protocols));
      if (protocol != null) {
        sslContextFactory.setProtocol(protocol);
      } else {
        logger.warn(ManagementStrings.SSL_PROTOCOAL_COULD_NOT_BE_DETERMINED);
      }

      if (StringUtils.isBlank(sysProps.getProperty("javax.net.ssl.keyStore"))) {
        throw new GemFireConfigException(
            "Key store can't be empty if SSL is enabled for HttpService");
      }

      sslContextFactory.setKeyStorePath(sysProps.getProperty("javax.net.ssl.keyStore"));

      if (!StringUtils.isBlank(sysProps.getProperty("javax.net.ssl.keyStoreType"))) {
        sslContextFactory.setKeyStoreType(sysProps.getProperty("javax.net.ssl.keyStoreType"));
      }

      if (!StringUtils.isBlank(sysProps.getProperty("javax.net.ssl.keyStorePassword"))) {
        sslContextFactory.setKeyStorePassword(
            sysProps.getProperty("javax.net.ssl.keyStorePassword"));
      }

      if (!StringUtils.isBlank(sysProps.getProperty("javax.net.ssl.trustStore"))) {
        sslContextFactory.setTrustStorePath(sysProps.getProperty("javax.net.ssl.trustStore"));
      }

      if (!StringUtils.isBlank(sysProps.getProperty("javax.net.ssl.trustStorePassword"))) {
        sslContextFactory.setTrustStorePassword(
            sysProps.getProperty("javax.net.ssl.trustStorePassword"));
      }

      httpConfig.addCustomizer(new SecureRequestCustomizer());

      // Somehow With HTTP_2.0 Jetty throwing NPE. Need to investigate further whether all GemFire
      // web application(Pulse, REST) can do with HTTP_1.1
      connector =
          new ServerConnector(
              jettyServer,
              new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
              new HttpConnectionFactory(httpConfig));

      connector.setPort(port);
    } else {
      connector = new ServerConnector(jettyServer, new HttpConnectionFactory(httpConfig));

      connector.setPort(port);
    }

    jettyServer.setConnectors(new Connector[] {connector});

    if (!StringUtils.isBlank(bindAddress)) {
      connector.setHost(bindAddress);
    }

    if (bindAddress != null && !bindAddress.isEmpty()) {
      JettyHelper.bindAddress = bindAddress;
    }

    JettyHelper.port = port;

    return jettyServer;
  }