Refine search
private Set<String> namespacesBelongToAppId(String appId, Set<String> namespaces) { if (ConfigConsts.NO_APPID_PLACEHOLDER.equalsIgnoreCase(appId)) { return Collections.emptySet(); } List<AppNamespace> appNamespaces = appNamespaceService.findByAppIdAndNamespaces(appId, namespaces); if (appNamespaces == null || appNamespaces.isEmpty()) { return Collections.emptySet(); } return FluentIterable.from(appNamespaces).transform(AppNamespace::getName).toSet(); } }
public LoadMeasureComputersStep(MutableMeasureComputersHolder measureComputersHolder, Metrics[] metricsRepositories, MeasureComputer[] measureComputers) { this.measureComputersHolder = measureComputersHolder; this.measureComputers = measureComputers; this.pluginMetricKeys = from(Arrays.asList(metricsRepositories)) .transformAndConcat(MetricsToMetricList.INSTANCE) .transform(MetricToKey.INSTANCE) .toSet(); }
private void createAppMasterRole(String appId, String operator) { Set<Permission> appPermissions = FluentIterable.from(Lists.newArrayList( PermissionType.CREATE_CLUSTER, PermissionType.CREATE_NAMESPACE, PermissionType.ASSIGN_ROLE)) .transform(permissionType -> createPermission(appId, permissionType, operator)).toSet(); Set<Permission> createdAppPermissions = rolePermissionService.createPermissions(appPermissions); Set<Long> appPermissionIds = createdAppPermissions.stream().map(BaseEntity::getId).collect(Collectors.toSet()); //create app master role Role appMasterRole = createRole(RoleUtils.buildAppMasterRoleName(appId), operator); rolePermissionService.createRoleWithPermissions(appMasterRole, appPermissionIds); }
/** * Create permissions, note that permissionType + targetId should be unique */ @Transactional public Set<Permission> createPermissions(Set<Permission> permissions) { Multimap<String, String> targetIdPermissionTypes = HashMultimap.create(); for (Permission permission : permissions) { targetIdPermissionTypes.put(permission.getTargetId(), permission.getPermissionType()); } for (String targetId : targetIdPermissionTypes.keySet()) { Collection<String> permissionTypes = targetIdPermissionTypes.get(targetId); List<Permission> current = permissionRepository.findByPermissionTypeInAndTargetId(permissionTypes, targetId); Preconditions.checkState(CollectionUtils.isEmpty(current), "Permission with permissionType %s targetId %s already exists!", permissionTypes, targetId); } Iterable<Permission> results = permissionRepository.saveAll(permissions); return FluentIterable.from(results).toSet(); }
public Set<ValueAttribute> getUniqueAttributeBuilderAttributes() { if (uniqueNestedBuilderAttributes == null) { uniqueNestedBuilderAttributes = FluentIterable.from(getSettableAttributes()) .filter(ValueAttributeFunctions.isAttributeBuilder()) .filter(ValueAttributeFunctions.uniqueOnAttributeBuilderDescriptor()) .toSet(); } return uniqueNestedBuilderAttributes; }
public Set<ValueAttribute> getUniqueAttributeBuilderListAttributes() { if (uniqueAttributeBuilderListAttributes == null) { uniqueAttributeBuilderListAttributes = FluentIterable.from(getSettableAttributes()) .filter(ValueAttributeFunctions.isListType()) .filter(ValueAttributeFunctions.isAttributeBuilder()) .filter(ValueAttributeFunctions.uniqueOnAttributeBuilderDescriptor()) .toSet(); } return uniqueAttributeBuilderListAttributes; }
@Override public ImmutableSet<String> get() { List<String> extensions = Lists.newArrayList(); // best effort to read it from compilation classpath if (StaticEnvironment.isInitialized()) { try { String lines = getClasspathResourceText( StaticEnvironment.processing().getFiler(), resource); extensions.addAll(RESOURCE_SPLITTER.splitToList(lines)); } catch (RuntimeException | IOException cannotReadCompilationClasspath) { // we ignore this as we did or best effort // and there are no plans to halt whole compilation } } ClassLoader classLoader = ExtensionLoader.class.getClassLoader(); try { Enumeration<URL> resources = classLoader.getResources(resource); while (resources.hasMoreElements()) { URL nextElement = resources.nextElement(); String lines = Resources.toString(nextElement, StandardCharsets.UTF_8); extensions.addAll(RESOURCE_SPLITTER.splitToList(lines)); } } catch (RuntimeException | IOException cannotReadAnnotationProcessingClasspath) { // we ignore this as we did or best effort // and there are no plans to halt whole compilation } return FluentIterable.from(extensions).toSet(); } });
private Set<String> useProvidedTypesForServices(TypeElement typeElement, ImmutableList<TypeMirror> typesMirrors) { List<String> wrongTypes = Lists.newArrayList(); List<String> types = Lists.newArrayList(); for (TypeMirror typeMirror : typesMirrors) { if (typeMirror.getKind() != TypeKind.DECLARED || !processing().getTypeUtils().isAssignable(typeElement.asType(), typeMirror)) { wrongTypes.add(typeMirror.toString()); } else { types.add(typeMirror.toString()); } } if (!wrongTypes.isEmpty()) { processing().getMessager().printMessage( Diagnostic.Kind.ERROR, "@Metainf.Service(value = {...}) contains types that are not implemented by " + typeElement.getSimpleName() + ": " + wrongTypes, typeElement, AnnotationMirrors.findAnnotation(typeElement.getAnnotationMirrors(), Metainf.Service.class)); } return FluentIterable.from(types).toSet(); }
/** * Query users with role */ public Set<UserInfo> queryUsersWithRole(String roleName) { Role role = findRoleByRoleName(roleName); if (role == null) { return Collections.emptySet(); } List<UserRole> userRoles = userRoleRepository.findByRoleId(role.getId()); Set<UserInfo> users = FluentIterable.from(userRoles).transform(userRole -> { UserInfo userInfo = new UserInfo(); userInfo.setUserId(userRole.getUserId()); return userInfo; }).toSet(); return users; }
private void removeServerSegment(final DruidServerMetadata server, final DataSegment segment) { synchronized (lock) { log.debug("Segment[%s] is gone from server[%s]", segment.getId(), server.getName()); final Map<DataSegment, SegmentMetadataHolder> knownSegments = segmentMetadataInfo.get(segment.getDataSource()); final SegmentMetadataHolder holder = knownSegments.get(segment); final Map<SegmentId, Set<String>> segmentServerMap = holder.getReplicas(); final ImmutableSet<String> servers = FluentIterable.from(segmentServerMap.get(segment.getId())) .filter(Predicates.not(Predicates.equalTo(server.getName()))) .toSet(); final SegmentMetadataHolder holderWithNumReplicas = SegmentMetadataHolder .from(holder) .withReplicas(ImmutableMap.of(segment.getId(), servers)) .build(); knownSegments.put(segment, holderWithNumReplicas); lock.notifyAll(); } }