/** * Returns a thread-safe, {@code Serializable} lazy reference to the core component which is stored in JIRA's * Dependency Injection container under the key that is the given class. * * @param componentClass class to find a component instance by * @return the dependency injection component reference * @see ComponentReference */ @ExperimentalApi public static <T> ComponentReference<T> getComponentReference(@Nonnull Class<T> componentClass) { return new ComponentReference<T>(componentClass); }
/** * We need to do this cause we cannot assign the cluster manager in initialization * * @return the cluster manager */ private ClusterManager getClusterManager() { return clusterManagerRef.get(); }
private ClusterManager getClusterManager() { return clusterManagerRef.get(); }
private void reIndexComment(final Comment comment) { try { indexingServiceReference.get().reIndexComments(Collections.singletonList(comment)); } catch (final Exception commentReindexException) //catch everything here to make sure it doesn't bring server down. { log.error("Error re-indexing comment '" + comment.getId() + "'", commentReindexException); } }
private void reIndexWorklog(final Worklog worklog) { try { indexingServiceReference.get().reIndexWorklogs(Collections.singletonList(worklog)); } catch (final Exception worklogReindexException) //catch everything here to make sure it doesn't bring server down. { log.error("Error re-indexing worklog '" + worklog.getId() + "'", worklogReindexException); } }
@Override public void afterInstantiation() throws Exception { final EventPublisher eventPublisher = eventPublisherRef.get(); eventPublisher.register(this); eventPublisher.register(this.features); }
@Override public boolean hasSiteEditPermission() { final ApplicationUser loggedInUser = authenticationContext.getLoggedInUser(); return permissionManagerRef.get().hasPermission(GlobalPermissionKey.ADMINISTER, loggedInUser); }
public void restoreIndex(String fileName) { if (clusterManagerRef.get().isClustered()) { LOG.info("Index restore started. Snapshot file: {}", fileName); final File backupFile = new File(sharedIndexPath, fileName); try { indexRecoveryManager.recoverIndexFromBackup(backupFile, TaskProgressSink.NULL_SINK); } catch (IndexException e) { throw new RuntimeException(e); } eventPublisher.publish(IndexesRestoredEvent.INSTANCE); LOG.info("Index restore complete"); } }
@Override public void refreshLiveNodes() { final Collection<String> heartbeatLiveNodesIds = heartbeatServiceRef.get().findLiveNodes(); Collection<Node> filter = CollectionUtil.filter(getAllNodes(), new Predicate<Node>() { @Override public boolean evaluate(final Node node) { return node != null && node.getState() == ACTIVE && heartbeatLiveNodesIds.contains(node.getNodeId()); } }); liveNodes = ImmutableSet.<Node>copyOf(filter); }
private void reIndex(final IssueEvent issueEvent, IssueIndexingParams issueIndexingParams) { final Set<Issue> issuesToReindex = new HashSet<>(); final Issue issue = issueEvent.getIssue(); issuesToReindex.add(issue); //if there are any subtasks that were modified as part of an issue operation (e.g. editing a parent issue's //security level) ensure that they are also re-indexed. if (issueEvent.isSubtasksUpdated()) { issuesToReindex.addAll(issue.getSubTaskObjects()); } try { indexingServiceReference.get().reIndexIssueObjects(issuesToReindex, issueIndexingParams); } catch (final Exception issueReindexException) //catch everything here to make sure it doesn't bring server down. { log.error("Error re-indexing changes for issue '" + issue.getKey() + "'", issueReindexException); } }
public String backupIndex(String requestingNode, final IndexSnapshotContribution contribution) { if (clusterManagerRef.get().isClustered()) { LOG.info("Index backup started. Requesting node: {}", requestingNode); // nodes not having index should not respond final String nodeId = clusterManagerRef.get().getNodeId(); final Long latestOperation = ofBizNodeIndexOperationStore.getLatestOperation(nodeId); if (latestOperation == null) { LOG.warn("Index backup failed - latest index operation not found. Requesting node: {}", requestingNode); return null; } Long backupId = delegatorInterface.getNextSeqId(INDEX_BACKUP_SEQUENCE); String backupFileName = copyIndex(localIndexPath, sharedIndexPath, backupId, contribution); if (!requestingNode.equals(nodeId)) { messageHandlerService.sendMessage(requestingNode, new Message(BACKUP_INDEX_DONE, backupFileName)); } LOG.info("Index backup complete. Snapshot file: {}", backupFileName); return backupFileName; } return null; }
public CacheHolder() { CacheSettings cacheSettings = new CacheSettingsBuilder().expireAfterAccess(30, TimeUnit.MINUTES).build(); mailServerCache = cacheManagerRef.get().getCache(CACHE_NAME, new MailServerCacheLoader(), cacheSettings); CacheSettings allCacheSettings = new CacheSettingsBuilder().expireAfterAccess(30, TimeUnit.MINUTES).build(); allMailServerCache = cacheManagerRef.get().getCachedReference(ALL_CACHE_NAME, new AllMailServersSupplier(), allCacheSettings); eventPublisherRef.get().register(this); }
@Override public void start() { final DatabaseConfig databaseConfig = dbcmRef.get().getDatabaseConfiguration(); if (databaseConfig.isEmbeddedDatabase()) { if (databaseConfig.isHSql()) { // export HSQL only exportAndHalt(); } else if (exportFile().exists()) { // import to H2 when the HSQL export is present; it will be moved after import importAndContinue(); } } }
final DatabaseConfigurationManager dbcm = dbcmRef.get();
private void changeSiteDarkFeature(final String feature, final boolean enable) { if (!hasSiteEditPermission()) { throw new IllegalStateException("User " + authenticationContext.getLoggedInUser() + " does not have permission to change site dark features"); } final Set<String> enabledFeatures = getSiteEnabledFeatures(); if (enable == enabledFeatures.contains(feature)) { // No change to make - feature is already enabled or disabled. return; } if (enable) { featureStore.create(feature, null); enabledFeatures.add(feature); } else { featureStore.delete(feature, null); enabledFeatures.remove(feature); } siteFeatures.reset(); darkFeatures.removeAll(); eventPublisherRef.get().publish(enable ? new FeatureEnabledEvent(feature) : new FeatureDisabledEvent(feature)); }
@Override public void start() { DatabaseConfig databaseConfig = configManagerRef.get().getDatabaseConfiguration(); if (databaseConfig == null) { log.error("No database config found"); return; } // Add the datasource and delegator final DatasourceInfo datasourceInfo = databaseConfig.getDatasourceInfo(); if (datasourceInfo == null) { log.error("No datasource info found"); return; } showEmbeddedDbWarning(databaseConfig); setupHsqlHacks(datasourceInfo); initDatabaseTransactions(datasourceInfo); // JRADEV-23357 clean up table name case sensitivity problems cleanupDatabaseTableNames(); new JiraStartupLogger().printStartingMessageDatabaseOK(); }
private void changeUserDarkFeature(final ApplicationUser user, final String feature, final boolean enable) { // Check 'dark feature' key against CoreFeatures - users should not attempt to // enable or disable them. final CoreFeatures coreFeature = CoreFeatures.forFeatureKey(feature); if (coreFeature != null && !coreFeature.isDevFeature()) { throw new IllegalStateException("User cannot set feature '" + feature + "' at runtime. It must be set by an admin via properties."); } final Set<String> enabledFeatures = Sets.newHashSet(getUserEnabledFeatures(user)); if (enable == enabledFeatures.contains(feature)) { // No change to make - feature is already enabled or disabled. return; } if (enable) { featureStore.create(feature, user.getKey()); enabledFeatures.add(feature); } else { featureStore.delete(feature, user.getKey()); enabledFeatures.remove(feature); } userFeaturesCache.remove(user.getKey()); darkFeatures.removeAll(); eventPublisherRef.get().publish(enable ? new FeatureEnabledEvent(feature, user) : new FeatureDisabledEvent(feature, user)); }
@Override public Option<Document> apply(final Issue issueObject) { if (LOG.isDebugEnabled()) { LOG.debug("Indexing issue: " + issueObject.getKey()); } //noinspection ConstantConditions return new Builder(issueObject) .addAll(fieldIndexerManagerRef.get().getAllIssueIndexers()) .addAllExtractors(searchExtractorManager.findExtractorsForEntity(Issue.class)) .build(); }
@Override public void stop() { shutdownHsqlHacks(); final DatabaseConfig config = configManagerRef.get().getDatabaseConfiguration(); if (config != null) { // shutting down even though database was not yet set up String name = config.getDatasourceName(); final EntityConfigUtil entityConfigUtil = EntityConfigUtil.getInstance(); // check if delegator was ever configured if (entityConfigUtil.getDelegatorInfo(name) != null) { entityConfigUtil.removeDelegator(name); } // check if datasource was ever configured if (entityConfigUtil.getDatasourceInfo(name) != null) { entityConfigUtil.removeDatasource(name); } } }