Try to get a {@link LineageInfo} instance from the given {@link SharedResourcesBroker}
761736
public static Optional<LineageInfo> getLineageInfo(@Nullable SharedResourcesBroker<GobblinScopeTypes> broker) {
    if (broker == null) {
      log.warn("Null broker. Will not track data lineage");
      return Optional.absent();
    }

    try {
      LineageInfo lineageInfo = broker.getSharedResource(new LineageInfoFactory(), EmptyKey.INSTANCE);
      return Optional.of(lineageInfo);
    } catch (NotConfiguredException e) {
      log.warn("Fail to get LineageInfo instance from broker. Will not track data lineage", e);
      return Optional.absent();
    }
  }
1091174
private SnapshotInfo getRestorePlan() throws Exception {
        // Wait for ZK to publish the snapshot fragment/info structures.
        List<String> children = waitOnVoltZK_restore();

        // If not recovering, nothing to do.
        if (m_action.doesRequireEmptyDirectories()) {
            return null;
        }

        Map<String, Set<SnapshotInfo>> snapshotFragments = new HashMap<String, Set<SnapshotInfo>>();
        Long clStartTxnId = deserializeRestoreInformation(children, snapshotFragments);

        // If command log has no snapshot requirement clear the fragment set directly
        if (clStartTxnId != null && clStartTxnId == Long.MIN_VALUE) {
            snapshotFragments.clear();
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("There are " + snapshotFragments.size() + " restore candidate snapshots available in the cluster");
        }

        // Find the last complete snapshot and use it
        HashMap<String, Map<String, Set<Integer>>> snapshotTablePartitions =
            new HashMap<String, Map<String,Set<Integer>>>();
        Iterator<Entry<String, Set<SnapshotInfo>>> it = snapshotFragments.entrySet().iterator();
        SnapshotInfo newest = null;
        while (it.hasNext()) {
            Entry<String, Set<SnapshotInfo>> e = it.next();
            Set<String> fileTables = new HashSet<String>();
            Set<String> digestTables = null;
            String nonce = e.getKey();
            Map<String, Set<Integer>> tablePartitions = snapshotTablePartitions.get(nonce);
            if (tablePartitions == null) {
                tablePartitions = new HashMap<String, Set<Integer>>();
                snapshotTablePartitions.put(nonce, tablePartitions);
            }

            int totalPartitions = -1;
            boolean inconsistent = false;
            Set<SnapshotInfo> fragments = e.getValue();
            for (SnapshotInfo s : fragments) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("SnapshotInfo " + s.nonce + " claims digest tables: " + s.digestTables);
                    LOG.debug("SnapshotInfo " + s.nonce + " claims files for tables: " + s.fileTables);
                }
                if (digestTables == null) {
                    digestTables = new HashSet<String>(s.digestTables);
                }
                else if (!digestTables.equals(s.digestTables)) {
                    m_snapshotErrLogStr.append("\nRejected snapshot ")
                                    .append(s.nonce)
                                    .append(" due to disagreement in digest table list.  Got ")
                                    .append(s.digestTables)
                                    .append(", expecting ")
                                    .append(digestTables);
                    inconsistent = true;
                    break;
                }
                fileTables.addAll(s.fileTables);
                if (totalPartitions == -1) {
                    totalPartitions = s.partitionCount;
                } else if (totalPartitions != s.partitionCount) {
                    m_snapshotErrLogStr.append("\nRejected snapshot ")
                                    .append(s.nonce)
                                    .append(" due to partition count mismatch. Got ")
                                    .append(s.partitionCount)
                                    .append(", expecting ")
                                    .append(totalPartitions);
                    inconsistent = true;
                    break;
                }

                for (Entry<String, Set<Integer>> entry : s.partitions.entrySet()) {
                    Set<Integer> partitions = tablePartitions.get(entry.getKey());
                    if (partitions == null) {
                        tablePartitions.put(entry.getKey(), entry.getValue());
                    } else {
                        partitions.addAll(entry.getValue());
                    }
                }

                if (inconsistent) {
                    break;
                }
            }

            // Check that we have files for all the tables listed in the digest
            if (!fileTables.equals(digestTables)) {
                m_snapshotErrLogStr.append("\nRejected snapshot ")
                    .append(nonce)
                    .append(" because there were not table files for all tables in the digest.  Expected ")
                    .append(digestTables)
                    .append(", but only found table data for ")
                    .append(fileTables);
                inconsistent = true;
            }

            // Check if we have all the partitions
            for (Set<Integer> partitions : tablePartitions.values()) {
                if (partitions.size() != totalPartitions) {
                    m_snapshotErrLogStr.append("\nRejected snapshot ")
                                    .append(nonce)
                                    .append(" due to missing partitions. Got ")
                                    .append(partitions.size())
                                    .append(", expecting ")
                                    .append(totalPartitions);
                    inconsistent = true;
                }
            }

            if (inconsistent) {
                it.remove();
            }
            else {
                SnapshotInfo current = consolidateSnapshotInfos(fragments);
                if (newest == null || current.isNewerThan(newest)) {
                    newest = current;
                }
            }
        }

        // If we have a command log and it requires a snapshot but no snapshot
        // fragments were found, simply bail (or, if we didn't find a viable
        // snapshot from which to recover)
        // Reluctant to muck with the first predicate here, even though
        // the newest == null should cover all of the 'no viable snapshot' possiblities
        if ((clStartTxnId != null && clStartTxnId != Long.MIN_VALUE &&
            snapshotFragments.size() == 0) || newest == null) {
            if (m_snapshotErrLogStr.length() > 0) {
                LOG.error(m_snapshotErrLogStr.toString());
            }
            throw new RuntimeException("No viable snapshots to restore");
        }

        if (snapshotFragments.isEmpty()) {
            return null;
        } else {
            return newest;
        }
    }
751565
public static ForkThrowableHolder getForkThrowableHolder(SharedResourcesBroker<GobblinScopeTypes> broker) {
    try {
      return broker.getSharedResource(new ForkThrowableHolderFactory(), EmptyKey.INSTANCE);
    } catch (NotConfiguredException e) {
      LOG.error("Fail to get fork throwable holder instance from broker. Will not track fork exception.", e);
      throw new RuntimeException(e);
    }
  }
1094970
LinkedHashMap/*< String, SharedFlowController >*/ getDefaultSharedFlows( RequestContext context )
            throws ClassNotFoundException, InstantiationException, IllegalAccessException
    {
        SharedFlowRefConfig[] defaultRefs = ConfigUtil.getConfig().getSharedFlowRefs();

        if ( defaultRefs != null )
        {
            if ( defaultRefs.length > 0 )
            {
                LinkedHashMap/*< String, SharedFlowController >*/ sharedFlows = new LinkedHashMap();

                for ( int i = 0; i < defaultRefs.length; i++ )
                {
                    SharedFlowRefConfig ref = defaultRefs[i];
                    if ( LOG.isInfoEnabled() )
                    {
                        LOG.info( "Shared flow of type " + ref.getType() + " is a default shared flow reference "
                                    + "with name " + ref.getName() );
                    }
                    addSharedFlow( context, ref.getName(), ref.getType(), sharedFlows );
                }

                return sharedFlows;
            }
        }

        return null;
    }
851380
@Override
    @FFDCIgnore(NoSuchMethodException.class)
    public XAResource getXAResource(Serializable xaresinfo) throws XAResourceNotAvailableException {
        XAResource xa = null;
        if (xaresinfo != null) {
            @SuppressWarnings("unchecked")
            ArrayList<Byte> byteList = (ArrayList<Byte>) xaresinfo;
            byte[] bytes = new byte[byteList.size()];
            int i = 0;
            for (Byte b : byteList)
                bytes[i++] = b;
            try {
                ActivationConfig config = (ActivationConfig) Utils.deserialize(bytes);
                Object activationSpec = createActivationSpec(config.getActivationConfigProps(),
                                                             config.getAuthenticationAlias(),
                                                             null,
                                                             config.getDestinationRef(),
                                                             null,
                                                             config.getApplicationName());
                if (qmidenabled) {
                    Class<? extends Object> mcImplClass = activationSpec.getClass();
                    try {
                        String qmid = config.getQmid();
                        Method m = mcImplClass.getMethod("setQmid", new Class[] { String.class });
                        m.invoke(activationSpec, qmid);
                    } catch (NoSuchMethodException nsme) {
                        qmidenabled = false;
                    } catch (InvocationTargetException ite) {
                        qmidenabled = false;
                    }
                }
                BootstrapContextImpl bootstrapContext = bootstrapContextRef.getServiceWithException();
                ActivationSpec[] actspecs = new ActivationSpec[] { (ActivationSpec) activationSpec };
                XAResource[] resources = bootstrapContext.resourceAdapter.getXAResources(actspecs);
                if (resources != null && resources.length == 1) {
                    xa = resources[0];
                } else if (resources != null && resources.length > 1) {
                    throw new IllegalStateException(Utils.getMessage("J2CA8800.multiple.xa.resources", bootstrapContext.getResourceAdapterName(), id));
                }
            } catch (Exception e) {
                throw new XAResourceNotAvailableException(e);
            }
        }
        return xa;
    }
912689
public Object getCloudantClient(ResourceInfo info) throws Exception {
        return cloudantSvc.getCloudantClient(
                                             info == null ? ResourceInfo.AUTH_APPLICATION : info.getAuth(),
                                             info == null ? null : info.getLoginPropertyList());
    }
1173191
@Override
    public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) {
        for (ExchangeRateProvider prov : this.providers) {
            try {
                if (prov.isAvailable(conversionQuery)) {
                    ExchangeRate rate = prov.getExchangeRate(conversionQuery);
                    if (rate!=null) {
                        return rate;
                    }
                }
            } catch (Exception e) {
                Logger.getLogger(getClass().getName()).log(Level.WARNING,
                        "Rate Provider did not return data though at check before data was flagged as available," +
                                " provider=" + prov.getContext().getProviderName() + ", query=" + conversionQuery);
            }
        }
        throw new CurrencyConversionException(conversionQuery.getBaseCurrency(), conversionQuery.getCurrency(), null,
                "All delegate prov iders failed to deliver rate, providers=" + this.providers +
                        ", query=" + conversionQuery);
    }
223039
public CMISInfo getCMISInfo(final Class<? extends GraphObject> type) {

		try { return type.newInstance().getCMISInfo(); } catch (Throwable t) {}

		return null;
	}
694822
@Nullable
  public Object getSharedResource(@Nonnull final String name) {
    assertNotNull("Name is null", name);
    return sharedResources.get(name);
  }
20607
@SuppressWarnings(value = "unchecked")
  <T, K extends SharedResourceKey> T getAutoScoped(final SharedResourceFactory<T, K, S> factory, final K key,
      final SharedResourcesBrokerImpl<S> broker)
      throws ExecutionException {

    // figure out auto scope
    RawJobBrokerKey autoscopeCacheKey = new RawJobBrokerKey(broker.getWrappedSelfScope(), factory.getName(), key);
    ScopeWrapper<S> selectedScope = this.autoScopeCache.get(autoscopeCacheKey, new Callable<ScopeWrapper<S>>() {
      @Override
      public ScopeWrapper<S> call() throws Exception {
        return broker.getWrappedScope(factory.getAutoScope(broker, broker.getConfigView(null, key, factory.getName())));
      }
    });

    // get actual object
    return getScoped(factory, key, selectedScope, broker);
  }
66337
@Override
    public <T> CachedResource<T> getResource(
            Resource resource, Loader<T> builder, long checkInterval) throws IOException {
        if (Included.PLAIN == this.resourcesElementsProvider.getDefaultIncludedType()) {
            this.logger.trace(
                    "Resoure Aggregation Disabled, ignoring resource cache and loading '"
                            + resource
                            + "' directly");
            return this.loadResource(resource, builder);
        }

        // Look for the resource in the cache, since it has been wrapped with a SelfPopulatingCache
        // it should never return null.
        final GetResourceArguments<T> arguments = new GetResourceArguments<T>(resource, builder);
        final Element element =
                this.entryFactory.getWithData(this.resourceCache, resource, arguments);

        CachedResource<T> cachedResource = (CachedResource<T>) element.getObjectValue();
        if (this.logger.isTraceEnabled()) {
            this.logger.trace("Found " + cachedResource + " in cache");
        }

        // Found it, now check if the last-load time is within the check interval
        final long lastCheckTime = cachedResource.getLastCheckTime();
        if (lastCheckTime + checkInterval >= System.currentTimeMillis()) {
            if (this.logger.isTraceEnabled()) {
                this.logger.trace(
                        cachedResource
                                + " is within checkInterval "
                                + checkInterval
                                + ", returning");
            }
            return cachedResource;
        }
        if (this.logger.isTraceEnabled()) {
            this.logger.trace(
                    cachedResource
                            + " is older than checkInterval "
                            + checkInterval
                            + ", checking for modification");
        }

        // If the resource has not been modified return the cached resource.
        final boolean resourceModified = this.checkIfModified(cachedResource);
        if (!resourceModified) {
            cachedResource.setLastCheckTime(System.currentTimeMillis());
            this.resourceCache.put(
                    element); // do a cache put to notify the cache the object has been modified
            return cachedResource;
        }

        // The resource has been modified, reload it.
        cachedResource = this.loadResource(resource, builder);

        // Cache the loaded resource
        this.resourceCache.put(new Element(resource, cachedResource));

        if (this.logger.isDebugEnabled()) {
            this.logger.debug("Loaded and cached " + cachedResource);
        }

        return cachedResource;
    }
827140
public static <S extends ScopeType<S>> FileSystem get(URI uri, Configuration configuration, SharedResourcesBroker<S> broker)
    throws IOException {
    try {
      return broker.getSharedResource(new FileSystemFactory<S>(), new FileSystemKey(uri, configuration));
    } catch (NotConfiguredException nce) {
      throw new IOException(nce);
    }
  }
1003504
public static LineageEventBuilder fromEvent(GobblinTrackingEvent event) {
    Map<String, String> metadata = event.getMetadata();
    LineageEventBuilder lineageEvent = new LineageEventBuilder(event.getName());

    metadata.forEach((key, value) -> {
      switch (key) {
        case SOURCE:
          lineageEvent.setSource(Descriptor.fromJson(value));
          break;
        case DESTINATION:
          lineageEvent.setDestination(Descriptor.fromJson(value));
          break;
        default:
          lineageEvent.addMetadata(key, value);
          break;
      }
    });

    return lineageEvent;
  }
515608
@Override
	@Transactional(propagation = Propagation.NEVER)
	public List<Long> getResources(final String theUuid, int theFrom, int theTo) {
		TransactionTemplate txTemplate = new TransactionTemplate(myManagedTxManager);
		txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);

		Search search;
		StopWatch sw = new StopWatch();
		while (true) {

			if (myNeverUseLocalSearchForUnitTests == false) {
				BaseTask task = myIdToSearchTask.get(theUuid);
				if (task != null) {
					ourLog.trace("Local search found");
					List<Long> resourcePids = task.getResourcePids(theFrom, theTo);
					if (resourcePids != null) {
						return resourcePids;
					}
				}
			}

			search = txTemplate.execute(t -> mySearchDao.findByUuid(theUuid));

			if (search == null) {
				ourLog.debug("Client requested unknown paging ID[{}]", theUuid);
				String msg = myContext.getLocalizer().getMessage(PageMethodBinding.class, "unknownSearchId", theUuid);
				throw new ResourceGoneException(msg);
			}

			verifySearchHasntFailedOrThrowInternalErrorException(search);
			if (search.getStatus() == SearchStatusEnum.FINISHED) {
				ourLog.debug("Search entity marked as finished with {} results", search.getNumFound());
				break;
			}
			if (search.getNumFound() >= theTo) {
				ourLog.debug("Search entity has {} results so far", search.getNumFound());
				break;
			}

			if (sw.getMillis() > myMaxMillisToWaitForRemoteResults) {
				ourLog.error("Search {} of type {} for {}{} timed out after {}ms", search.getId(), search.getSearchType(), search.getResourceType(), search.getSearchQueryString(), sw.getMillis());
				throw new InternalErrorException("Request timed out after " + sw.getMillis() + "ms");
			}

			// If the search was saved in "pass complete mode" it's probably time to
			// start a new pass
			if (search.getStatus() == SearchStatusEnum.PASSCMPLET) {
				Optional<Search> newSearch = tryToMarkSearchAsInProgress(search);
				if (newSearch.isPresent()) {
					search = newSearch.get();
					String resourceType = search.getResourceType();
					SearchParameterMap params = search.getSearchParameterMap();
					IFhirResourceDao<?> resourceDao = myDaoRegistry.getResourceDao(resourceType);
					SearchContinuationTask task = new SearchContinuationTask(search, resourceDao, params, resourceType);
					myIdToSearchTask.put(search.getUuid(), task);
					myExecutor.submit(task);
				}
			}

			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
				// ignore
			}
		}

		final Pageable page = toPage(theFrom, theTo);
		if (page == null) {
			return Collections.emptyList();
		}

		final Search foundSearch = search;

		ourLog.trace("Loading stored search");
		List<Long> retVal = txTemplate.execute(theStatus -> {
			final List<Long> resultPids = new ArrayList<>();
			Page<Long> searchResultPids = mySearchResultDao.findWithSearchUuid(foundSearch, page);
			for (Long next : searchResultPids) {
				resultPids.add(next);
			}
			return resultPids;
		});
		return retVal;
	}
707349
DataSource getDataSource() {
        if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
            LoggingUtil.SESSION_LOGGER_WAS.entering(methodClassName, methodNames[GET_DATA_SOURCE]);
        }

        if (dataSource != null)
            return dataSource;

        try {

            //            Properties p = new Properties();
            //
            //            p.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
            //            InitialContext ic = new javax.naming.InitialContext(p);
            beginDBContext(); // PK06395/d321615
            //            dataSource = (DataSource) ic.lookup(_smc.getJNDIDataSourceName());

            ResourceConfig rc = this.getDatabaseStoreService().getResourceConfigFactory().createResourceConfig("javax.sql.DataSource");
            rc.setResAuthType(ResourceConfig.AUTH_CONTAINER);
            rc.setSharingScope(ResourceConfig.SHARING_SCOPE_SHAREABLE);
            rc.setIsolationLevel(Connection.TRANSACTION_READ_COMMITTED);
            //            ResRef.APPLICATION, // resAuth - org.eclipse.jst.j2ee.common.ResAuthTypeBase.APPLICATION=
            //            ResRef.SHAREABLE, // resSharingScope - org.eclipse.jst.j2ee.common.ResSharingScopeType.SHAREABLE
            //            ResRef.TRANSACTION_READ_COMMITTED); // resIsolationLevel - com.ibm.ejs.models.base.extensions.commonext.IsolationLevelKind.TRANSACTION_READ_COMMITTED
            dataSource = (DataSource) this.getDatabaseStoreService().getDataSourceFactory().createResource(rc);

            //            dataSource = (DataSource)SessionMgrComponentImpl.getDataSourceFactory().createResource(null); // direct JNDI lookup
            endDBContext(); // PK06395/d321615
            return dataSource;

        } catch (Exception e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.session.store.db.DatabaseHashMap.getDataSource", "558", this);
            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[GET_DATA_SOURCE], "DatabaseHashMap.dataSrcErr");
            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[GET_DATA_SOURCE], "CommonMessage.exception", e);
            dataSource = null;
        }
        return null;
    }
636495
@Override
    @GraphTransaction
    public String getOutputsGraph(String datasetName) throws AtlasException {
        LOG.info("Fetching lineage outputs graph for datasetName={}", datasetName);
        datasetName = ParamChecker.notEmpty(datasetName, "dataset name");
        TypeUtils.Pair<String, String> typeIdPair = validateDatasetNameExists(datasetName);
        return getOutputsGraphForId(typeIdPair.right);
    }
1323765
public RequestViewMetadata cloneInstance()
    {
        RequestViewMetadata rvm = new RequestViewMetadata();
        rvm.initialProcessedClasses = new HashMap<Class<?>, Boolean>(
                this.initialProcessedClasses != null ? 
                    this.initialProcessedClasses : this.processedClasses);
        if (this.initialAddedResources != null)
        {
            rvm.initialAddedResources = new HashMap<ResourceDependency, Boolean>(
                    this.initialAddedResources);
        }
        else if (this.addedResources != null)
        {
            rvm.initialAddedResources = new HashMap<ResourceDependency, Boolean>(
                    this.addedResources);
        }
        return rvm;
    }