public static ArrayList<byte[]> copyToNewArrays(Collection<ByteRange> ranges) { if (ranges == null) { return new ArrayList<>(0); } ArrayList<byte[]> arrays = Lists.newArrayListWithCapacity(ranges.size()); for (ByteRange range : ranges) { arrays.add(range.deepCopyToNewArray()); } return arrays; }
public static ArrayList<ByteRange> fromArrays(Collection<byte[]> arrays) { if (arrays == null) { return new ArrayList<>(0); } ArrayList<ByteRange> ranges = Lists.newArrayListWithCapacity(arrays.size()); for (byte[] array : arrays) { ranges.add(new SimpleMutableByteRange(array)); } return ranges; }
@Override public List<InputSplit> getSplits(JobContext jobContext) throws IOException, InterruptedException { List<TableSnapshotInputFormatImpl.InputSplit> splits = delegate.getSplits(jobContext.getConfiguration()); List<InputSplit> rtn = Lists.newArrayListWithCapacity(splits.size()); for (TableSnapshotInputFormatImpl.InputSplit split : splits) { rtn.add(new TableSnapshotInputFormat.TableSnapshotRegionSplit(split)); } return rtn; }
/** * A utility used to grant a user namespace permissions. * <p> * It's also called by the shell, in case you want to find references. * * @param controller RpcController * @param protocol the AccessControlService protocol proxy * @param namespace the short name of the user to grant permissions * @param actions the permissions to be granted * @throws ServiceException * @deprecated Use {@link Admin#grant(UserPermission, boolean)} instead. */ @Deprecated public static void grant(RpcController controller, AccessControlService.BlockingInterface protocol, String userShortName, String namespace, boolean mergeExistingPermissions, Permission.Action... actions) throws ServiceException { List<AccessControlProtos.Permission.Action> permActions = Lists.newArrayListWithCapacity(actions.length); for (Permission.Action a : actions) { permActions.add(toPermissionAction(a)); } AccessControlProtos.GrantRequest request = buildGrantRequest(userShortName, namespace, mergeExistingPermissions, permActions.toArray(new AccessControlProtos.Permission.Action[actions.length])); protocol.grant(controller, request); }
/** * A utility used to grant a user global permissions. * <p> * It's also called by the shell, in case you want to find references. * * @param protocol the AccessControlService protocol proxy * @param userShortName the short name of the user to grant permissions * @param actions the permissions to be granted * @throws ServiceException * @deprecated Use {@link Admin#grant(UserPermission, boolean)} instead. */ @Deprecated public static void grant(RpcController controller, AccessControlService.BlockingInterface protocol, String userShortName, boolean mergeExistingPermissions, Permission.Action... actions) throws ServiceException { List<AccessControlProtos.Permission.Action> permActions = Lists.newArrayListWithCapacity(actions.length); for (Permission.Action a : actions) { permActions.add(toPermissionAction(a)); } AccessControlProtos.GrantRequest request = buildGrantRequest(userShortName, mergeExistingPermissions, permActions.toArray(new AccessControlProtos.Permission.Action[actions.length])); protocol.grant(controller, request); }
/** * A utility used to revoke a user's global permissions. * <p> * It's also called by the shell, in case you want to find references. * * @param controller RpcController * @param protocol the AccessControlService protocol proxy * @param userShortName the short name of the user to revoke permissions * @param actions the permissions to be revoked * @throws ServiceException on failure * @deprecated Use {@link Admin#grant(UserPermission, boolean)} instead. */ @Deprecated public static void revoke(RpcController controller, AccessControlService.BlockingInterface protocol, String userShortName, Permission.Action... actions) throws ServiceException { List<AccessControlProtos.Permission.Action> permActions = Lists.newArrayListWithCapacity(actions.length); for (Permission.Action a : actions) { permActions.add(toPermissionAction(a)); } AccessControlProtos.RevokeRequest request = buildRevokeRequest(userShortName, permActions.toArray(new AccessControlProtos.Permission.Action[actions.length])); protocol.revoke(controller, request); }
/** * A utility used to revoke a user's namespace permissions. * <p> * It's also called by the shell, in case you want to find references. * * @param controller RpcController * @param protocol the AccessControlService protocol proxy * @param userShortName the short name of the user to revoke permissions * @param namespace optional table name * @param actions the permissions to be revoked * @throws ServiceException on failure * @deprecated Use {@link Admin#grant(UserPermission, boolean)} instead. */ @Deprecated public static void revoke(RpcController controller, AccessControlService.BlockingInterface protocol, String userShortName, String namespace, Permission.Action... actions) throws ServiceException { List<AccessControlProtos.Permission.Action> permActions = Lists.newArrayListWithCapacity(actions.length); for (Permission.Action a : actions) { permActions.add(toPermissionAction(a)); } AccessControlProtos.RevokeRequest request = buildRevokeRequest(userShortName, namespace, permActions.toArray(new AccessControlProtos.Permission.Action[actions.length])); protocol.revoke(controller, request); }
/** * A utility used to revoke a user's table permissions. The permissions will * be for a table/column family/qualifier. * <p> * It's also called by the shell, in case you want to find references. * * @param controller RpcController * @param protocol the AccessControlService protocol proxy * @param userShortName the short name of the user to revoke permissions * @param tableName optional table name * @param f optional column family * @param q optional qualifier * @param actions the permissions to be revoked * @throws ServiceException on failure * @deprecated Use {@link Admin#grant(UserPermission, boolean)} instead. */ @Deprecated public static void revoke(RpcController controller, AccessControlService.BlockingInterface protocol, String userShortName, TableName tableName, byte[] f, byte[] q, Permission.Action... actions) throws ServiceException { List<AccessControlProtos.Permission.Action> permActions = Lists.newArrayListWithCapacity(actions.length); for (Permission.Action a : actions) { permActions.add(toPermissionAction(a)); } AccessControlProtos.RevokeRequest request = buildRevokeRequest(userShortName, tableName, f, q, permActions.toArray(new AccessControlProtos.Permission.Action[actions.length])); protocol.revoke(controller, request); }
/** * A utility used to grant a user table permissions. The permissions will * be for a table table/column family/qualifier. * <p> * It's also called by the shell, in case you want to find references. * * @param protocol the AccessControlService protocol proxy * @param userShortName the short name of the user to grant permissions * @param tableName optional table name * @param f optional column family * @param q optional qualifier * @param actions the permissions to be granted * @throws ServiceException * @deprecated Use {@link Admin#grant(UserPermission, boolean)} instead. */ @Deprecated public static void grant(RpcController controller, AccessControlService.BlockingInterface protocol, String userShortName, TableName tableName, byte[] f, byte[] q, boolean mergeExistingPermissions, Permission.Action... actions) throws ServiceException { List<AccessControlProtos.Permission.Action> permActions = Lists.newArrayListWithCapacity(actions.length); for (Permission.Action a : actions) { permActions.add(toPermissionAction(a)); } AccessControlProtos.GrantRequest request = buildGrantRequest(userShortName, tableName, f, q, mergeExistingPermissions, permActions.toArray(new AccessControlProtos.Permission.Action[actions.length])); protocol.grant(controller, request); }
public static List<HRegionInfo> getRegionInfosFromManifest(SnapshotManifest manifest) { List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests(); if (regionManifests == null) { throw new IllegalArgumentException("Snapshot seems empty"); } List<HRegionInfo> regionInfos = Lists.newArrayListWithCapacity(regionManifests.size()); for (SnapshotRegionManifest regionManifest : regionManifests) { HRegionInfo hri = HRegionInfo.convert(regionManifest.getRegionInfo()); if (hri.isOffline() && (hri.isSplit() || hri.isSplitParent())) { continue; } regionInfos.add(hri); } return regionInfos; }
/** * Produces a list containing copies of the current state of all non-expired * MonitoredTasks handled by this TaskMonitor. * @param filter type of wanted tasks * @return A filtered list of MonitoredTasks. */ public synchronized List<MonitoredTask> getTasks(String filter) { purgeExpiredTasks(); TaskFilter taskFilter = createTaskFilter(filter); ArrayList<MonitoredTask> results = Lists.newArrayListWithCapacity(tasks.size() + rpcTasks.size()); processTasks(tasks, taskFilter, results); processTasks(rpcTasks, taskFilter, results); return results; }
/** * Find the List of HRegions based on a list of region specifiers * * @param regionSpecifiers the list of region specifiers * @return the corresponding list of regions * @throws IOException if any of the specifiers is not null, * but failed to find the region */ private List<HRegion> getRegions(final List<RegionSpecifier> regionSpecifiers, final CacheEvictionStatsBuilder stats) { List<HRegion> regions = Lists.newArrayListWithCapacity(regionSpecifiers.size()); for (RegionSpecifier regionSpecifier: regionSpecifiers) { try { regions.add(regionServer.getRegion(regionSpecifier.getValue().toByteArray())); } catch (NotServingRegionException e) { stats.addException(regionSpecifier.getValue().toByteArray(), e); } } return regions; }
List<FileStatus> validFiles = Lists.newArrayListWithCapacity(files.size()); List<FileStatus> invalidFiles = Lists.newArrayList(); for (FileStatus file : files) {
Lists.newArrayListWithCapacity(candidateSelection.size()); long maxTimestampSeen = Long.MIN_VALUE; for (HStoreFile storeFile : candidateSelection) {
List<RowLock> acquiredRowLocks = Lists.newArrayListWithCapacity(batchOp.size()); try {
/** * A utility used to grant a user global permissions. * <p> * It's also called by the shell, in case you want to find references. * * @param protocol the AccessControlService protocol proxy * @param userShortName the short name of the user to grant permissions * @param actions the permissions to be granted * @throws ServiceException */ public static void grant(RpcController controller, AccessControlService.BlockingInterface protocol, String userShortName, boolean mergeExistingPermissions, Permission.Action... actions) throws ServiceException { List<AccessControlProtos.Permission.Action> permActions = Lists.newArrayListWithCapacity(actions.length); for (Permission.Action a : actions) { permActions.add(toPermissionAction(a)); } AccessControlProtos.GrantRequest request = buildGrantRequest(userShortName, mergeExistingPermissions, permActions.toArray(new AccessControlProtos.Permission.Action[actions.length])); protocol.grant(controller, request); }
/** * A utility used to grant a user namespace permissions. * <p> * It's also called by the shell, in case you want to find references. * * @param protocol the AccessControlService protocol proxy * @param namespace the short name of the user to grant permissions * @param actions the permissions to be granted * @throws ServiceException */ public static void grant(RpcController controller, AccessControlService.BlockingInterface protocol, String userShortName, String namespace, boolean mergeExistingPermissions, Permission.Action... actions) throws ServiceException { List<AccessControlProtos.Permission.Action> permActions = Lists.newArrayListWithCapacity(actions.length); for (Permission.Action a : actions) { permActions.add(toPermissionAction(a)); } AccessControlProtos.GrantRequest request = buildGrantRequest(userShortName, namespace, mergeExistingPermissions, permActions.toArray(new AccessControlProtos.Permission.Action[actions.length])); protocol.grant(controller, request); }
/** * A utility used to revoke a user's namespace permissions. * <p> * It's also called by the shell, in case you want to find references. * * @param protocol the AccessControlService protocol proxy * @param userShortName the short name of the user to revoke permissions * @param namespace optional table name * @param actions the permissions to be revoked * @throws ServiceException */ public static void revoke(RpcController controller, AccessControlService.BlockingInterface protocol, String userShortName, String namespace, Permission.Action... actions) throws ServiceException { List<AccessControlProtos.Permission.Action> permActions = Lists.newArrayListWithCapacity(actions.length); for (Permission.Action a : actions) { permActions.add(toPermissionAction(a)); } AccessControlProtos.RevokeRequest request = buildRevokeRequest(userShortName, namespace, permActions.toArray(new AccessControlProtos.Permission.Action[actions.length])); protocol.revoke(controller, request); }
/** * A utility used to revoke a user's global permissions. * <p> * It's also called by the shell, in case you want to find references. * * @param protocol the AccessControlService protocol proxy * @param userShortName the short name of the user to revoke permissions * @param actions the permissions to be revoked * @throws ServiceException */ public static void revoke(RpcController controller, AccessControlService.BlockingInterface protocol, String userShortName, Permission.Action... actions) throws ServiceException { List<AccessControlProtos.Permission.Action> permActions = Lists.newArrayListWithCapacity(actions.length); for (Permission.Action a : actions) { permActions.add(toPermissionAction(a)); } AccessControlProtos.RevokeRequest request = buildRevokeRequest(userShortName, permActions.toArray(new AccessControlProtos.Permission.Action[actions.length])); protocol.revoke(controller, request); }
/** * A utility used to revoke a user's table permissions. The permissions will * be for a table/column family/qualifier. * <p> * It's also called by the shell, in case you want to find references. * * @param protocol the AccessControlService protocol proxy * @param userShortName the short name of the user to revoke permissions * @param tableName optional table name * @param f optional column family * @param q optional qualifier * @param actions the permissions to be revoked * @throws ServiceException */ public static void revoke(RpcController controller, AccessControlService.BlockingInterface protocol, String userShortName, TableName tableName, byte[] f, byte[] q, Permission.Action... actions) throws ServiceException { List<AccessControlProtos.Permission.Action> permActions = Lists.newArrayListWithCapacity(actions.length); for (Permission.Action a : actions) { permActions.add(toPermissionAction(a)); } AccessControlProtos.RevokeRequest request = buildRevokeRequest(userShortName, tableName, f, q, permActions.toArray(new AccessControlProtos.Permission.Action[actions.length])); protocol.revoke(controller, request); }