/*
(non-Javadoc)

@see
org.duracloud.mill.ltp.LoopingTaskProducer#loadMorselQueueFromSource(java
.util.Queue)
541574
@Override
    protected void loadMorselQueueFromSource(Queue<StorageStatsMorsel> morselQueue) {
        // generate set of morsels based on duplication policy
        try {
            for (String account : getAccountsList()) {
                String accountPath = "/" + account;

                log.debug("loading {}", account);

                if (exclusionManager.isExcluded(accountPath)) {
                    continue;
                }

                AccountCredentials accountCreds = getCredentialsRepo().getAccountCredentials(account);
                for (StorageProviderCredentials cred : accountCreds.getProviderCredentials()) {
                    String storePath = accountPath + "/" + cred.getProviderId();
                    if (exclusionManager.isExcluded(storePath)) {
                        continue;
                    }

                    StorageProvider store = getStorageProvider(cred);

                    Iterator<String> spaces = store.getSpaces();
                    while (spaces.hasNext()) {
                        String spaceId = spaces.next();
                        String spacePath = storePath + "/" + spaceId;
                        if (!exclusionManager.isExcluded(spacePath)) {
                            morselQueue.add(new StorageStatsMorsel(account,
                                                                   cred.getProviderId(),
                                                                   cred.getProviderType().name(),
                                                                   spaceId));
                        }
                    }

                    log.info("loaded {} into morsel queue.", account);

                }
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new DuraCloudRuntimeException(e);
        }
    }
78699
@Override
	public void connectToResourceManager(@Nonnull ResourceManagerGateway resourceManagerGateway) {
		this.resourceManagerGateway = checkNotNull(resourceManagerGateway);

		// work on all slots waiting for this connection
		for (PendingRequest pendingRequest : waitingForResourceManager.values()) {
			requestSlotFromResourceManager(resourceManagerGateway, pendingRequest);
		}

		// all sent off
		waitingForResourceManager.clear();
	}
1004361
@Override
    public void updateRemoteQueuePointSet(Set newQueuePointLocalisingMEUuids)
                    throws SIResourceException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "updateRemoteQueuePointSet",
                        new Object[] {
                                      newQueuePointLocalisingMEUuids,
                                      this });

        _localisationManager.updateRemoteQueuePointSet(newQueuePointLocalisingMEUuids,
                                                       _postMediatedItemStreamsRequiringCleanup);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "updateRemoteQueuePointSet");

    }
118257
public void addAsyncResource(JTAAsyncResourceBase resource) throws SystemException
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "addAsyncResource", new Object[] { this, resource });

        if (_asyncResourceObjects == null) {
            _asyncResourceObjects = new ArrayList<JTAAsyncResourceBase>();
        } else {
            for (JTAAsyncResourceBase asyncRes : _asyncResourceObjects) {
                if (resource.getKey().equals(asyncRes.getKey())) {
                    // Caller to determine appropriate action
                    final SystemException se = new SystemException("Cannot register two asynchronous resources with the same keys: " + asyncRes.getKey());
                    if (tc.isEntryEnabled())
                        Tr.exit(tc, "addAsyncResource", se);
                    throw se;
                }
            }
        }

        resource.setResourceStatus(StatefulResource.REGISTERED);
        _asyncResourceObjects.add(resource);

        if (tc.isEventEnabled())
            Tr.event(tc, "(SPI) SERVER registered with Transaction. TX: " + _transaction.getLocalTID() + ", Resource: " + resource);

        if (tc.isEntryEnabled())
            Tr.exit(tc, "addAsyncResource");
    }
20916
public static <V> StrategicBlockingQueue<V> newStrategicLinkedBlockingQueue(QueueingStrategy<V> queueingStrategy) {
        return new StrategicBlockingQueue<V>(new LinkedBlockingQueue<V>(), queueingStrategy);
    }
1165522
public <T> T loadResources(Class<T> type, String... resources) {
    return loadResources(type, Arrays.asList(resources));
  }
88356
public void setQueueList(List<String> queueList) throws RabbitmqCommunicateException
    {
        if (queueList == null || queueList.size() == 0)
        {
            String message = "QueueList is not defined.";
            throw new RabbitmqCommunicateException(message);
        }
        this.queueList = queueList;
    }
1169634
protected void load(int offset, int limit) {
        if (!completed) {
            LoadingEvent.fire(this, offset, offset + (limit - 1));
            dataSource.load(new LoadConfig<>(offset, limit), new LoadCallback<T>() {
                @Override
                public void onSuccess(LoadResult<T> loadResult) {
                    LoadedEvent.fire(InfiniteScrollPanel.this, loadResult);
                    InfiniteScrollPanel.this.offset = InfiniteScrollPanel.this.offset + limit;

                    if (InfiniteScrollPanel.this.offset >= loadResult.getTotalLength()) {
                        CompleteEvent.fire(InfiniteScrollPanel.this, loadResult.getTotalLength());
                    }
                }

                @Override
                public void onFailure(Throwable caught) {
                    ErrorEvent.fire(InfiniteScrollPanel.this, caught.getMessage());
                }
            });
        }
    }
896924
@Override
    public java.util.concurrent.Future<ListQueueTagsResult> listQueueTagsAsync(String queueUrl,
            com.amazonaws.handlers.AsyncHandler<ListQueueTagsRequest, ListQueueTagsResult> asyncHandler) {

        return listQueueTagsAsync(new ListQueueTagsRequest().withQueueUrl(queueUrl), asyncHandler);
    }
1298050
@Override
    public Queue createQueue(String queueName) throws JMSRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createQueue", new Object[] { queueName });

        Queue queue = null;
        try {
            queue = jmsSession.createQueue(queueName);
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createQueue", new Object[] { queue });
        }

        return queue;
    }
33163
private void updateQueue(String dataSourceName, DataSourceCompactionConfig config)
  {
    final CompactibleTimelineObjectHolderCursor compactibleTimelineObjectHolderCursor = timelineIterators.get(
        dataSourceName
    );

    if (compactibleTimelineObjectHolderCursor == null) {
      log.warn("Cannot find timeline for dataSource[%s]. Skip this dataSource", dataSourceName);
      return;
    }

    final SegmentsToCompact segmentsToCompact = findSegmentsToCompact(
        compactibleTimelineObjectHolderCursor,
        config
    );

    if (segmentsToCompact.getNumSegments() > 1) {
      queue.add(new QueueEntry(segmentsToCompact.segments));
    }
  }
350111
final ForkJoinTask<?> nextTaskFor(WorkQueue w) {
        for (ForkJoinTask<?> t;;) {
            WorkQueue q;
            if ((t = w.nextLocalTask()) != null)
                return t;
            if ((q = findNonEmptyStealQueue()) == null)
                return null;
            if ((t = q.pollAt(q.base)) != null)
                return t;
        }
    }
610645
@Override
    protected void loadMorselQueueFromSource(Queue<DuplicationMorsel> morselQueue) {
        //generate set of morsels based on duplication policy
        for (String account : this.policyManager.getDuplicationAccounts()) {
            DuplicationPolicy policy = this.policyManager.getDuplicationPolicy(account);
            try {
                final CredentialsRepo credRepo = getCredentialsRepo();
                if (getCredentialsRepo().isAccountActive(account)) {
                    AccountCredentials accountCreds = credRepo.getAccountCredentials(account);
                    for (StorageProviderCredentials cred : accountCreds.getProviderCredentials()) {
                        if (cred.isPrimary()) {
                            StorageProvider provider = getStorageProvider(cred);
                            Iterator<String> spaces = provider.getSpaces();
                            while (spaces.hasNext()) {
                                String spaceId = spaces.next();
                                Set<DuplicationStorePolicy> storePolicies = policy.getDuplicationStorePolicies(spaceId);
                                for (DuplicationStorePolicy storePolicy : storePolicies) {
                                    morselQueue.add(new DuplicationMorsel(account, spaceId, null, storePolicy));
                                }
                            }
                        }
                    }
                }
            } catch (AccountCredentialsNotFoundException e) {
                throw new RuntimeException(e);
            }
        }
    }
524911
public void loadPath(
        final String sitePath,
        final boolean continueIfNotLoaded,
        final AsyncCallback<CmsClientSitemapEntry> callback) {

        if (getEntry(sitePath) != null) {
            CmsClientSitemapEntry entry = getEntry(sitePath);
            getChildren(entry.getId(), CmsSitemapTreeItem.getItemById(entry.getId()).isOpen(), callback);
        } else {
            String parentPath = CmsResource.getParentFolder(sitePath);
            CmsUUID idToLoad = null;
            CmsClientSitemapEntry entry = getEntry(parentPath);
            while (entry == null) {
                parentPath = CmsResource.getParentFolder(parentPath);
                if (parentPath == null) {
                    break;
                } else {
                    entry = getEntry(parentPath);
                }
            }
            if (entry != null) {
                idToLoad = entry.getId();
            } else {
                idToLoad = m_data.getSiteRootId();
            }
            CmsSitemapTreeItem treeItem = CmsSitemapTreeItem.getItemById(idToLoad);
            boolean open = true;
            if (treeItem != null) {
                open = treeItem.isOpen();
            }
            getChildren(idToLoad, open, continueIfNotLoaded, new AsyncCallback<CmsClientSitemapEntry>() {

                public void onFailure(Throwable caught) {

                    // nothing to do
                }

                public void onSuccess(CmsClientSitemapEntry result) {

                    // check if target entry is loaded
                    CmsClientSitemapEntry target = getEntry(sitePath);
                    if (target == null) {
                        loadPath(sitePath, continueIfNotLoaded, callback);
                    } else {
                        if (callback != null) {
                            callback.onSuccess(target);
                        }
                    }
                }
            });
        }
    }
1133224
public <T> T loadImpl(Class<T> service) {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        if (loader == null) {
            loader = ClassLoader.getSystemClassLoader();
        }
        Enumeration<URL> resources;
        try {
            resources = loader.getResources("mockito-extensions/" + service.getName());
        } catch (IOException e) {
            throw new IllegalStateException("Failed to load " + service, e);
        }

        try {
            String classOrAlias = new PluginFinder(pluginSwitch).findPluginClass(Iterables.toIterable(resources));
            if (classOrAlias != null) {
                if (classOrAlias.equals(alias)) {
                    classOrAlias = plugins.getDefaultPluginClass(alias);
                }
                Class<?> pluginClass = loader.loadClass(classOrAlias);
                Object plugin = pluginClass.newInstance();
                return service.cast(plugin);
            }
            return null;
        } catch (Exception e) {
            throw new IllegalStateException(
                "Failed to load " + service + " implementation declared in " + resources, e);
        }
    }
768608
@Override
    public java.util.concurrent.Future<GetQueueUrlResult> getQueueUrlAsync(String queueName) {

        return getQueueUrlAsync(new GetQueueUrlRequest().withQueueName(queueName));
    }
607593
protected final JsEngineComponent loadClass(String className, int stopSeq, boolean reportError) {

        String thisMethodName = "loadClass";

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.entry(tc, thisMethodName, new Object[] { className, Integer.toString(stopSeq), Boolean.toString(reportError) });
        }

        Class myClass = null;
        JsEngineComponent retValue = null;

        int _seq = stopSeq;
        if (_seq < 0 || _seq > NUM_STOP_PHASES) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(tc, "loadClass: stopSeq is out of bounds " + stopSeq);
        } else {
            try {
                myClass = Class.forName(className);
                retValue = (JsEngineComponent) myClass.newInstance();
                ComponentList compList = new ComponentList(className, retValue);
                // No need to synchronize on jmeComponents to prevent concurrent
                // modification from dynamic config and runtime callbacks, because
                // jmeComponents is now a CopyOnWriteArrayList.
                jmeComponents.add(compList);
                stopSequence[_seq].addElement(compList);
            } catch (ClassNotFoundException e) {
                // No FFDC code needed
                if (reportError == true) {
                    com.ibm.ws.ffdc.FFDCFilter.processException(e, CLASS_NAME + ".loadClass", "3", this);
                    SibTr.error(tc, "CLASS_LOAD_FAILURE_SIAS0013", className);
                    SibTr.exception(tc, e);
                }

            } catch (InstantiationException e) {
                com.ibm.ws.ffdc.FFDCFilter.processException(e, CLASS_NAME + ".loadClass", "1", this);
                if (reportError == true) {
                    SibTr.error(tc, "CLASS_LOAD_FAILURE_SIAS0013", className);
                    SibTr.exception(tc, e);
                }

            } catch (Throwable e) {
                com.ibm.ws.ffdc.FFDCFilter.processException(e, CLASS_NAME + ".loadClass", "2", this);
                if (reportError == true) {
                    SibTr.error(tc, "CLASS_LOAD_FAILURE_SIAS0013", className);

                }
            }
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            if (retValue == null)
                SibTr.debug(tc, "loadClass: failed");
            else
                SibTr.debug(tc, "loadClass: OK");
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(tc, thisMethodName, retValue);
        }

        return retValue;
    }