protected String formatExtensionVersion(final String type, final BundleCoordinate bundle) { final String formattedType; if (BundleCoordinate.DEFAULT_VERSION.equals(bundle.getVersion())) { formattedType = type; } else { formattedType = type + " " + bundle.getVersion(); } final String formattedBundle; if (BundleCoordinate.DEFAULT_GROUP.equals(bundle.getGroup())) { formattedBundle = bundle.getId(); } else { formattedBundle = bundle.getGroup() + " - " + bundle.getId(); } return String.format("%s from %s", formattedType, formattedBundle); }
@Override public void verifyCanUpdateBundle(final BundleCoordinate incomingCoordinate) throws IllegalArgumentException { final BundleCoordinate existingCoordinate = getBundleCoordinate(); // determine if this update is changing the bundle for the processor if (!existingCoordinate.equals(incomingCoordinate)) { // if it is changing the bundle, only allow it to change to a different version within same group and id if (!existingCoordinate.getGroup().equals(incomingCoordinate.getGroup()) || !existingCoordinate.getId().equals(incomingCoordinate.getId())) { throw new IllegalArgumentException(String.format( "Unable to update component %s from %s to %s because bundle group and id must be the same.", getIdentifier(), existingCoordinate.getCoordinate(), incomingCoordinate.getCoordinate())); } } }
private void verifyBundleInSnippet(final BundleDTO requiredBundle, final Set<BundleCoordinate> supportedBundles) { final BundleCoordinate requiredCoordinate = new BundleCoordinate(requiredBundle.getGroup(), requiredBundle.getArtifact(), requiredBundle.getVersion()); if (!supportedBundles.contains(requiredCoordinate)) { throw new IllegalStateException("Unsupported bundle: " + requiredCoordinate); } }
protected void verifyCreate(final ExtensionManager extensionManager, final String type, final BundleDTO bundle) { final List<Bundle> bundles = extensionManager.getBundles(type); if (bundle != null) { final BundleCoordinate coordinate = new BundleCoordinate(bundle.getGroup(), bundle.getArtifact(), bundle.getVersion()); if (bundles.stream().filter(b -> b.getBundleDetails().getCoordinate().equals(coordinate)).count() == 0) { throw new IllegalStateException(String.format("%s is not known to this NiFi instance.", coordinate.toString())); } } else { if (bundles.isEmpty()) { throw new IllegalStateException(String.format("%s is not known to this NiFi instance.", type)); } else if (bundles.size() > 1) { throw new IllegalStateException(String.format("Multiple versions of %s exist. Please specify the desired bundle.", type)); } } } }
} else { final Set<BundleCoordinate> coordinates = bundleIdToCoordinatesLookup.get(bundleDependencyCoordinate.getId()); final String dependencyCoordinateStr = bundleDependencyCoordinate.getCoordinate(); logger.warn(String.format("While loading '%s' unable to locate exact NAR dependency '%s'. Only found one possible match '%s'. Continuing...", bundleDetail.getCoordinate().getCoordinate(), dependencyCoordinateStr, coordinate.getCoordinate()));
private static String getClassBundleKey(final String classType, final BundleCoordinate bundleCoordinate) { return classType + "_" + bundleCoordinate.getCoordinate(); }
if (registeredCoordinate.equals(bundleCoordinate)) { alreadyRegistered = true; break; + bundle.getBundleDetails().getCoordinate().getCoordinate() + " but that class name is already loaded/registered from " + registeredBundle.getBundleDetails().getCoordinate() + " and multiple versions are not supported for this type"
private BundleDetails(final Builder builder) { this.workingDirectory = builder.workingDirectory; this.coordinate = builder.coordinate; this.dependencyCoordinate = builder.dependencyCoordinate; this.buildTag = builder.buildTag; this.buildRevision = builder.buildRevision; this.buildBranch = builder.buildBranch; this.buildTimestamp = builder.buildTimestamp; this.buildJdk = builder.buildJdk; this.builtBy = builder.builtBy; if (this.coordinate == null) { if (this.workingDirectory == null) { throw new IllegalStateException("Coordinate cannot be null"); } else { throw new IllegalStateException("Coordinate cannot be null for " + this.workingDirectory.getAbsolutePath()); } } if (this.workingDirectory == null) { throw new IllegalStateException("Working directory cannot be null for " + this.coordinate.getId()); } }
public SystemDiagnosticsSnapshotDTO.VersionInfoDTO createVersionInfoDTO() { final SystemDiagnosticsSnapshotDTO.VersionInfoDTO dto = new SystemDiagnosticsSnapshotDTO.VersionInfoDTO(); dto.setJavaVendor(System.getProperty("java.vendor")); dto.setJavaVersion(System.getProperty("java.version")); dto.setOsName(System.getProperty("os.name")); dto.setOsVersion(System.getProperty("os.version")); dto.setOsArchitecture(System.getProperty("os.arch")); final Bundle frameworkBundle = NarClassLoadersHolder.getInstance().getFrameworkBundle(); if (frameworkBundle != null) { final BundleDetails frameworkDetails = frameworkBundle.getBundleDetails(); dto.setNiFiVersion(frameworkDetails.getCoordinate().getVersion()); // Get build info dto.setBuildTag(frameworkDetails.getBuildTag()); dto.setBuildRevision(frameworkDetails.getBuildRevision()); dto.setBuildBranch(frameworkDetails.getBuildBranch()); dto.setBuildTimestamp(frameworkDetails.getBuildTimestampDate()); } return dto; }
final BundleCoordinate bundleCoordinate = new BundleCoordinate(serviceBundleGroup, serviceBundleArtifact, serviceBundleVersion); final Bundle csBundle = getExtensionManager().getBundle(bundleCoordinate); if (csBundle == null) { throw new IllegalStateException("Unable to find bundle for coordinate " + bundleCoordinate.getCoordinate());
/** * Gets the bundle with the given coordinate. * * @param bundleCoordinate the coordinate of the bundle to find * @return the bundle with the coordinate, or an empty optional */ private Optional<Bundle> getBundle(final BundleCoordinate bundleCoordinate) { return initContext.bundles.values().stream() .filter(b -> b.getBundleDetails().getCoordinate().equals(bundleCoordinate)) .findFirst(); }
.anyMatch(b -> processorToAddCoordinate.equals(b.getBundleDetails().getCoordinate())); throw new IllegalArgumentException("Unknown bundle " + processorToAddCoordinate.toString() + " for processor type " + processorToAddClass); .anyMatch(b -> serviceToAddCoordinate.equals(b.getBundleDetails().getCoordinate())); throw new IllegalArgumentException("Unknown bundle " + serviceToAddCoordinate.toString() + " for service type " + serviceToAddClass);
@Override public String toString() { return coordinate.toString(); }
final String narCoordinate = narDetail.getCoordinate().getCoordinate(); if (narCoordinatesToWorkingDir.containsKey(narCoordinate)) { final String existingNarWorkingDir = narCoordinatesToWorkingDir.get(narCoordinate); if (JETTY_NAR_ID.equals(narDetail.getCoordinate().getId())) { narCoordinateClassLoaderLookup.put(narDetail.getCoordinate().getCoordinate(), jettyClassLoader); narDetailsIter.remove(); narIdBundleLookup.computeIfAbsent(narDetail.getCoordinate().getId(), id -> new HashSet<>()).add(narDetail.getCoordinate()); narClassLoader = createNarClassLoader(narDetail.getWorkingDirectory(), jettyClassLoader); } else { final String dependencyCoordinateStr = narDependencyCoordinate.getCoordinate(); final Set<BundleCoordinate> coordinates = narIdBundleLookup.get(narDependencyCoordinate.getId()); if (narCoordinateClassLoaderLookup.containsKey(coordinate.getCoordinate())) { logger.warn(String.format("While loading '%s' unable to locate exact NAR dependency '%s'. Only found one possible match '%s'. Continuing...", narDetail.getCoordinate().getCoordinate(), dependencyCoordinateStr, coordinate.getCoordinate())); final ClassLoader narDependencyClassLoader = narCoordinateClassLoaderLookup.get(coordinate.getCoordinate()); narClassLoader = createNarClassLoader(narDetail.getWorkingDirectory(), narDependencyClassLoader); if (bundleClassLoader != null) { narDirectoryBundleLookup.put(narDetail.getWorkingDirectory().getCanonicalPath(), new Bundle(narDetail, bundleClassLoader)); narCoordinateClassLoaderLookup.put(narDetail.getCoordinate().getCoordinate(), narClassLoader); narDetailsIter.remove();
final List<Bundle> compatibleBundles = extensionManager.getBundles(controllerServiceNode.getCanonicalClassName()).stream().filter(bundle -> { final BundleCoordinate coordinate = bundle.getBundleDetails().getCoordinate(); return bundleCoordinate.getGroup().equals(coordinate.getGroup()) && bundleCoordinate.getId().equals(coordinate.getId()); }).collect(Collectors.toList());
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof BundleCoordinate)) { return false; } final BundleCoordinate other = (BundleCoordinate) obj; return getCoordinate().equals(other.getCoordinate()); }
if (registeredCoordinate.equals(bundle.getBundleDetails().getCoordinate())) { alreadyRegistered = true; break; + bundle.getBundleDetails().getCoordinate().getCoordinate() + " but that class name is already loaded/registered from " + registeredBundle.getBundleDetails().getCoordinate() + " and multiple versions are not supported for this type"
final String bundleId = bundleDetail.getCoordinate().getId(); final Set<BundleCoordinate> coordinates = bundleIdToCoordinatesLookup.computeIfAbsent(bundleId, (id) -> new HashSet<>()); coordinates.add(bundleDetail.getCoordinate()); final String bundleId = bundleDetail.getCoordinate().getId(); final Set<BundleCoordinate> coordinates = bundleIdToCoordinatesLookup.computeIfAbsent(bundleId, (id) -> new HashSet<>()); coordinates.add(bundleDetail.getCoordinate()); for (final BundleDetails bundleDetail : additionalBundleDetails) { logger.warn(String.format("Unable to resolve required dependency '%s'. Skipping NAR '%s'", bundleDetail.getDependencyCoordinate().getId(), bundleDetail.getWorkingDirectory().getAbsolutePath())); skippedBundles.add(bundleDetail);
aboutDTO.setVersion(frameworkDetails.getCoordinate().getVersion());