Example #1
0
  public static void init() {
    String poolSize = PropertiesManager.getValue(PropertiesManager.KEY_JIRA_POOL_SIZE, "20");
    maxPoolSize = Convert.toInteger(poolSize);
    clientPool = new ArrayBlockingQueue<>(maxPoolSize, true);

    log.log(Level.FINE, MessageFormat.format("Filling Pool to: {0}", poolSize));
    ConnectionModel connectionModel = new ConnectionModel();
    connectionModel.setUrl(PropertiesManager.getValue(PropertiesManager.KEY_JIRA_URL));
    connectionModel.setUsername(PropertiesManager.getValue(PropertiesManager.KEY_TOOLS_USER));
    connectionModel.setCredential(
        PropertiesManager.getValue(PropertiesManager.KEY_TOOLS_CREDENTIALS));

    for (int i = 0; i < maxPoolSize; i++) {
      clientPool.offer(new JiraClient(connectionModel));
    }
  }
Example #2
0
 public static JiraClient getClient() {
   int waitTimeSeconds =
       Convert.toInteger(
           PropertiesManager.getValue(PropertiesManager.KEY_JIRA_CONNECTION_WAIT_TIME, "60"));
   try {
     JiraClient jiraClient = clientPool.poll(waitTimeSeconds, TimeUnit.SECONDS);
     if (jiraClient == null) {
       throw new OpenStorefrontRuntimeException(
           "Unable to retrieve Jira Connection in time.  No resource available.",
           "Adjust jira pool size appropriate to load or try again",
           ErrorTypeCode.INTEGRATION);
     }
     jiraClient.initConnection();
     return jiraClient;
   } catch (InterruptedException ex) {
     throw new OpenStorefrontRuntimeException(
         "Unable to retrieve Jira Connection - wait interrupted.  No resource available.",
         "Adjust jira pool size appropriate to load.",
         ex,
         ErrorTypeCode.INTEGRATION);
   }
 }