Search in sources :

Example 6 with ArrayUtils.addAll

use of org.apache.commons.lang3.ArrayUtils.addAll in project fess by codelibs.

the class LdapUser method getPermissions.

@Override
public String[] getPermissions() {
    if (permissions == null) {
        final FessConfig fessConfig = ComponentUtil.getFessConfig();
        final String baseDn = fessConfig.getLdapBaseDn();
        final String accountFilter = fessConfig.getLdapAccountFilter();
        final String groupFilter = fessConfig.getLdapGroupFilter();
        if (StringUtil.isNotBlank(baseDn) && StringUtil.isNotBlank(accountFilter)) {
            final LdapManager ldapManager = ComponentUtil.getLdapManager();
            permissions = distinct(ArrayUtils.addAll(ldapManager.getRoles(this, baseDn, accountFilter, groupFilter, roles -> {
                permissions = distinct(roles);
                ComponentUtil.getActivityHelper().permissionChanged(OptionalThing.of(new FessUserBean(this)));
            }), fessConfig.getRoleSearchUserPrefix() + ldapManager.normalizePermissionName(getName())));
        } else {
            permissions = StringUtil.EMPTY_STRINGS;
        }
    }
    return permissions;
}
Also used : FessUserBean(org.codelibs.fess.mylasta.action.FessUserBean) Arrays(java.util.Arrays) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) ComponentUtil(org.codelibs.fess.util.ComponentUtil) OptionalThing(org.dbflute.optional.OptionalThing) StringUtil(org.codelibs.core.lang.StringUtil) ArrayUtils(org.apache.commons.lang3.ArrayUtils) FessUser(org.codelibs.fess.entity.FessUser) Hashtable(java.util.Hashtable) FessUserBean(org.codelibs.fess.mylasta.action.FessUserBean) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Example 7 with ArrayUtils.addAll

use of org.apache.commons.lang3.ArrayUtils.addAll in project hbase by apache.

the class AssignmentManagerUtil method createAssignProcedures.

/**
 * Create assign procedures for the give regions, according to the {@code regionReplication}.
 * <p/>
 * For rolling back, we will submit procedures directly to the {@code ProcedureExecutor}, so it is
 * possible that we persist the newly scheduled procedures, and then crash before persisting the
 * rollback state, so when we arrive here the second time, it is possible that some regions have
 * already been associated with a TRSP.
 * @param ignoreIfInTransition if true, will skip creating TRSP for the given region if it is
 *          already in transition, otherwise we will add an assert that it should not in
 *          transition.
 */
private static TransitRegionStateProcedure[] createAssignProcedures(MasterProcedureEnv env, List<RegionInfo> regions, int regionReplication, ServerName targetServer, boolean ignoreIfInTransition) {
    // create the assign procs only for the primary region using the targetServer
    TransitRegionStateProcedure[] primaryRegionProcs = regions.stream().map(env.getAssignmentManager().getRegionStates()::getOrCreateRegionStateNode).map(regionNode -> {
        TransitRegionStateProcedure proc = TransitRegionStateProcedure.assign(env, regionNode.getRegionInfo(), targetServer);
        regionNode.lock();
        try {
            if (ignoreIfInTransition) {
                if (regionNode.isInTransition()) {
                    return null;
                }
            } else {
                // not process it either.
                assert !regionNode.isInTransition();
            }
            regionNode.setProcedure(proc);
        } finally {
            regionNode.unlock();
        }
        return proc;
    }).filter(p -> p != null).toArray(TransitRegionStateProcedure[]::new);
    if (regionReplication == DEFAULT_REGION_REPLICA) {
        // this is the default case
        return primaryRegionProcs;
    }
    // collect the replica region infos
    List<RegionInfo> replicaRegionInfos = new ArrayList<RegionInfo>(regions.size() * (regionReplication - 1));
    for (RegionInfo hri : regions) {
        // start the index from 1
        for (int i = 1; i < regionReplication; i++) {
            replicaRegionInfos.add(RegionReplicaUtil.getRegionInfoForReplica(hri, i));
        }
    }
    // create round robin procs. Note that we exclude the primary region's target server
    TransitRegionStateProcedure[] replicaRegionAssignProcs = env.getAssignmentManager().createRoundRobinAssignProcedures(replicaRegionInfos, Collections.singletonList(targetServer));
    // combine both the procs and return the result
    return ArrayUtils.addAll(primaryRegionProcs, replicaRegionAssignProcs);
}
Also used : IntStream(java.util.stream.IntStream) DEFAULT_HBASE_ENABLE_SEPARATE_CHILD_REGIONS(org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_ENABLE_SEPARATE_CHILD_REGIONS) ListIterator(java.util.ListIterator) GetRegionInfoResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse) FavoredNodesManager(org.apache.hadoop.hbase.favored.FavoredNodesManager) RegionReplicaUtil(org.apache.hadoop.hbase.client.RegionReplicaUtil) WALSplitUtil(org.apache.hadoop.hbase.wal.WALSplitUtil) IOException(java.io.IOException) ArrayUtils(org.apache.commons.lang3.ArrayUtils) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) Collectors(java.util.stream.Collectors) RequestConverter(org.apache.hadoop.hbase.shaded.protobuf.RequestConverter) ArrayList(java.util.ArrayList) GetRegionInfoRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoRequest) List(java.util.List) HConstants(org.apache.hadoop.hbase.HConstants) Stream(java.util.stream.Stream) FutureUtils(org.apache.hadoop.hbase.util.FutureUtils) InterfaceAudience(org.apache.yetus.audience.InterfaceAudience) AsyncRegionServerAdmin(org.apache.hadoop.hbase.client.AsyncRegionServerAdmin) Collections(java.util.Collections) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) ServerName(org.apache.hadoop.hbase.ServerName) ArrayList(java.util.ArrayList) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo)

Aggregations

ArrayUtils (org.apache.commons.lang3.ArrayUtils)6 Arrays (java.util.Arrays)3 List (java.util.List)3 IOException (java.io.IOException)2 Collections (java.util.Collections)2 Collectors (java.util.stream.Collectors)2 BreakendSummary (au.edu.wehi.idsv.BreakendSummary)1 LongArrayList (com.carrotsearch.hppc.LongArrayList)1 PPConfig (com.github.happyzleaf.pixelmonplaceholders.PPConfig)1 WeatherType (com.pixelmonmod.pixelmon.api.world.WeatherType)1 Attack (com.pixelmonmod.pixelmon.battles.attacks.Attack)1 DatabaseMoves (com.pixelmonmod.pixelmon.database.DatabaseMoves)1 DatabaseStats (com.pixelmonmod.pixelmon.database.DatabaseStats)1 DropItemRegistry (com.pixelmonmod.pixelmon.entities.npcs.registry.DropItemRegistry)1 PokemonDropInformation (com.pixelmonmod.pixelmon.entities.npcs.registry.PokemonDropInformation)1 EntityPixelmon (com.pixelmonmod.pixelmon.entities.pixelmon.EntityPixelmon)1 com.pixelmonmod.pixelmon.entities.pixelmon.stats (com.pixelmonmod.pixelmon.entities.pixelmon.stats)1 Evolution (com.pixelmonmod.pixelmon.entities.pixelmon.stats.evolution.Evolution)1 com.pixelmonmod.pixelmon.entities.pixelmon.stats.evolution.conditions (com.pixelmonmod.pixelmon.entities.pixelmon.stats.evolution.conditions)1 LevelingEvolution (com.pixelmonmod.pixelmon.entities.pixelmon.stats.evolution.types.LevelingEvolution)1