use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class AbstractPort method setName.
@Override
public void setName(final String name) {
if (this.name.get().equals(name)) {
return;
}
final ProcessGroup parentGroup = this.processGroup.get();
if (getConnectableType() == ConnectableType.INPUT_PORT) {
if (parentGroup.getInputPortByName(name) != null) {
throw new IllegalStateException("The requested new port name is not available");
}
} else if (getConnectableType() == ConnectableType.OUTPUT_PORT) {
if (parentGroup.getOutputPortByName(name) != null) {
throw new IllegalStateException("The requested new port name is not available");
}
}
this.name.set(name);
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class BulletinFactory method createBulletin.
public static Bulletin createBulletin(final Connectable connectable, final String category, final String severity, final String message) {
final ComponentType type;
switch(connectable.getConnectableType()) {
case REMOTE_INPUT_PORT:
case REMOTE_OUTPUT_PORT:
type = ComponentType.REMOTE_PROCESS_GROUP;
break;
case INPUT_PORT:
type = ComponentType.INPUT_PORT;
break;
case OUTPUT_PORT:
type = ComponentType.OUTPUT_PORT;
break;
case PROCESSOR:
default:
type = ComponentType.PROCESSOR;
break;
}
final ProcessGroup group = connectable.getProcessGroup();
final String groupId = group == null ? null : group.getIdentifier();
final String groupName = group == null ? null : group.getName();
return BulletinFactory.createBulletin(groupId, groupName, connectable.getIdentifier(), type, connectable.getName(), category, severity, message);
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class FlowController method startConnectable.
public void startConnectable(final Connectable connectable) {
final ProcessGroup group = requireNonNull(connectable).getProcessGroup();
writeLock.lock();
try {
if (initialized.get()) {
switch(requireNonNull(connectable).getConnectableType()) {
case FUNNEL:
group.startFunnel((Funnel) connectable);
break;
case INPUT_PORT:
case REMOTE_INPUT_PORT:
group.startInputPort((Port) connectable);
break;
case OUTPUT_PORT:
case REMOTE_OUTPUT_PORT:
group.startOutputPort((Port) connectable);
break;
default:
throw new IllegalArgumentException();
}
} else {
startConnectablesAfterInitialization.add(connectable);
}
} finally {
writeLock.unlock();
}
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class FlowController method updateProcessGroup.
//
// ProcessGroup access
//
/**
* Updates the process group corresponding to the specified DTO. Any field
* in DTO that is <code>null</code> (with the exception of the required ID)
* will be ignored.
*
* @param dto group
* @throws ProcessorInstantiationException
*
* @throws IllegalStateException if no process group can be found with the
* ID of DTO or with the ID of the DTO's parentGroupId, if the template ID
* specified is invalid, or if the DTO's Parent Group ID changes but the
* parent group has incoming or outgoing connections
*
* @throws NullPointerException if the DTO or its ID is null
*/
public void updateProcessGroup(final ProcessGroupDTO dto) throws ProcessorInstantiationException {
final ProcessGroup group = lookupGroup(requireNonNull(dto).getId());
final String name = dto.getName();
final PositionDTO position = dto.getPosition();
final String comments = dto.getComments();
if (name != null) {
group.setName(name);
}
if (position != null) {
group.setPosition(toPosition(position));
}
if (comments != null) {
group.setComments(comments);
}
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class FlowController method initializeFlow.
public void initializeFlow() throws IOException {
writeLock.lock();
try {
// get all connections/queues and recover from swap files.
final List<Connection> connections = getGroup(getRootGroupId()).findAllConnections();
long maxIdFromSwapFiles = -1L;
if (flowFileRepository.isVolatile()) {
for (final Connection connection : connections) {
final FlowFileQueue queue = connection.getFlowFileQueue();
queue.purgeSwapFiles();
}
} else {
for (final Connection connection : connections) {
final FlowFileQueue queue = connection.getFlowFileQueue();
final SwapSummary swapSummary = queue.recoverSwappedFlowFiles();
if (swapSummary != null) {
final Long maxFlowFileId = swapSummary.getMaxFlowFileId();
if (maxFlowFileId != null && maxFlowFileId > maxIdFromSwapFiles) {
maxIdFromSwapFiles = maxFlowFileId;
}
for (final ResourceClaim resourceClaim : swapSummary.getResourceClaims()) {
resourceClaimManager.incrementClaimantCount(resourceClaim);
}
}
}
}
flowFileRepository.loadFlowFiles(this, maxIdFromSwapFiles + 1);
// Begin expiring FlowFiles that are old
final RepositoryContextFactory contextFactory = new RepositoryContextFactory(contentRepository, flowFileRepository, flowFileEventRepository, counterRepositoryRef.get(), provenanceRepository);
processScheduler.scheduleFrameworkTask(new ExpireFlowFiles(this, contextFactory), "Expire FlowFiles", 30L, 30L, TimeUnit.SECONDS);
// now that we've loaded the FlowFiles, this has restored our ContentClaims' states, so we can tell the
// ContentRepository to purge superfluous files
contentRepository.cleanup();
for (final RemoteSiteListener listener : externalSiteListeners) {
listener.start();
}
notifyComponentsConfigurationRestored();
timerDrivenEngineRef.get().scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
try {
updateRemoteProcessGroups();
} catch (final Throwable t) {
LOG.warn("Unable to update Remote Process Groups due to " + t);
if (LOG.isDebugEnabled()) {
LOG.warn("", t);
}
}
}
}, 0L, 30L, TimeUnit.SECONDS);
timerDrivenEngineRef.get().scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
final ProcessGroup rootGroup = getRootGroup();
final List<ProcessGroup> allGroups = rootGroup.findAllProcessGroups();
allGroups.add(rootGroup);
for (final ProcessGroup group : allGroups) {
try {
group.synchronizeWithFlowRegistry(flowRegistryClient);
} catch (final Exception e) {
LOG.error("Failed to synchronize {} with Flow Registry", group, e);
}
}
}
}, 5, 60, TimeUnit.SECONDS);
initialized.set(true);
} finally {
writeLock.unlock();
}
}
Aggregations