/** Seed any users from the authority provider that are not already present. */ public void seedUserAccounts() { // do not seed node's user cache. when/if the node disconnects its // cache will be populated lazily (as needed) if (properties.isNode()) { return; } Transaction transaction = null; writeLock.lock(); try { // start the transaction transaction = transactionBuilder.start(); // seed the accounts SeedUserAccountsAction seedUserAccounts = new SeedUserAccountsAction(); transaction.execute(seedUserAccounts); // commit the transaction transaction.commit(); } catch (AdministrationException ae) { rollback(transaction); throw ae; } catch (Throwable t) { rollback(transaction); throw t; } finally { closeQuietly(transaction); writeLock.unlock(); } }
@Override public ThreadPoolRequestReplicator getObject() throws Exception { if (replicator == null && nifiProperties.isNode()) { final EventReporter eventReporter = applicationContext.getBean("eventReporter", EventReporter.class); final ClusterCoordinator clusterCoordinator = applicationContext.getBean("clusterCoordinator", ClusterCoordinator.class); final RequestCompletionCallback requestCompletionCallback = applicationContext.getBean("clusterCoordinator", RequestCompletionCallback.class); final int numThreads = nifiProperties.getClusterNodeProtocolThreads(); final Client jerseyClient = WebUtils.createClient( new DefaultClientConfig(), SslContextFactory.createSslContext(nifiProperties)); final String connectionTimeout = nifiProperties.getClusterNodeConnectionTimeout(); final String readTimeout = nifiProperties.getClusterNodeReadTimeout(); replicator = new ThreadPoolRequestReplicator( numThreads, jerseyClient, clusterCoordinator, connectionTimeout, readTimeout, requestCompletionCallback, eventReporter, nifiProperties); } return replicator; }
/** * Checks whether or not the request should be replicated to the cluster * * @return <code>true</code> if the request should be replicated, <code>false</code> otherwise */ boolean isReplicateRequest() { // If not a node in a cluster, we do not replicate if (!properties.isNode()) { return false; } if (!isConnectedToCluster()) { return false; } // Check if the X-Request-Replicated header is set. If so, the request has already been // replicated, // so we need to service the request locally. If not, then replicate the request to the entire // cluster. final String header = httpServletRequest.getHeader(RequestReplicator.REPLICATION_INDICATOR_HEADER); return header == null; }