public CreateTableProcedure(final MasterProcedureEnv env, final TableDescriptor tableDescriptor, final RegionInfo[] newRegions, final ProcedurePrepareLatch syncLatch) { super(env, syncLatch); this.tableDescriptor = tableDescriptor; this.newRegions = newRegions != null ? Lists.newArrayList(newRegions) : null; }
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; }
@Override public List<RSGroupInfo> listRSGroups() { return Lists.newLinkedList(rsGroupMap.values()); }
@Deprecated public static List<KeyValue> ensureKeyValues(List<Cell> cells) { List<KeyValue> lazyList = Lists.transform(cells, new Function<Cell, KeyValue>() { @Override public KeyValue apply(Cell arg0) { return KeyValueUtil.ensureKeyValue(arg0); } }); return new ArrayList<>(lazyList); } /**
synchronized List<LogMessage> getMessages() { // defensive copy return Lists.newArrayList(messages); }
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; }
public MemoryBoundedLogMessageBuffer(long maxSizeBytes) { Preconditions.checkArgument( maxSizeBytes > 0); this.maxSizeBytes = maxSizeBytes; this.messages = Lists.newLinkedList(); }
private void addRegionToMap(Map<ServerName, List<RegionInfo>> assignmentMapForFavoredNodes, RegionInfo region, ServerName host) { List<RegionInfo> regionsOnServer; if ((regionsOnServer = assignmentMapForFavoredNodes.get(host)) == null) { regionsOnServer = Lists.newArrayList(); assignmentMapForFavoredNodes.put(host, regionsOnServer); } regionsOnServer.add(region); }
@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; }
protected static RSGroupInfoManager getMockedGroupInfoManager() throws IOException { RSGroupInfoManager gm = Mockito.mock(RSGroupInfoManager.class); Mockito.when(gm.getRSGroup(Mockito.any())).thenAnswer(new Answer<RSGroupInfo>() { @Override public RSGroupInfo answer(InvocationOnMock invocation) throws Throwable { return groupMap.get(invocation.getArgument(0)); } }); Mockito.when(gm.listRSGroups()).thenReturn( Lists.newLinkedList(groupMap.values())); Mockito.when(gm.isOnline()).thenReturn(true); Mockito.when(gm.getRSGroupOfTable(Mockito.any())) .thenAnswer(new Answer<String>() { @Override public String answer(InvocationOnMock invocation) throws Throwable { return tableMap.get(invocation.getArgument(0)); } }); return gm; }
private Map<TableName, List<String>> copyTableCFs(Map<TableName, ? extends Collection<String>> tableCfs) { Map<TableName, List<String>> newTableCfs = new HashMap<>(); if (tableCfs != null) { tableCfs.forEach( (table, cfs) -> newTableCfs.put(table, cfs != null ? Lists.newArrayList(cfs) : null)); } return newTableCfs; }
/** * 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); }
private static Map<TableName, List<String>> copyTableCFsMap(Map<TableName, List<String>> preTableCfs) { Map<TableName, List<String>> newTableCfs = new HashMap<>(); preTableCfs.forEach( (table, cfs) -> newTableCfs.put(table, cfs != null ? Lists.newArrayList(cfs) : null)); return newTableCfs; }
/** * 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); }
@Override public List<WAL> getWALs() { if (wal != null) { return Lists.newArrayList(wal); } walCreateLock.readLock().lock(); try { if (wal == null) { return Collections.emptyList(); } else { return Lists.newArrayList(wal); } } finally { walCreateLock.readLock().unlock(); } }
/** * 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); }
void addToCompactionQueue(ServerName serverName, MajorCompactionRequest info) { this.lock.writeLock().lock(); try { List<MajorCompactionRequest> result = this.compactionQueues.get(serverName); if (result == null) { result = Lists.newArrayList(); compactionQueues.put(serverName, result); } result.add(info); } finally { this.lock.writeLock().unlock(); } }
/** * 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); }
private void mergeAssignmentMaps(Map<ServerName, List<RegionInfo>> assignmentMap, Map<ServerName, List<RegionInfo>> otherAssignments) { if (otherAssignments == null || otherAssignments.isEmpty()) { return; } for (Entry<ServerName, List<RegionInfo>> entry : otherAssignments.entrySet()) { ServerName sn = entry.getKey(); List<RegionInfo> regionsList = entry.getValue(); if (assignmentMap.get(sn) == null) { assignmentMap.put(sn, Lists.newArrayList(regionsList)); } else { assignmentMap.get(sn).addAll(regionsList); } } }
/** * 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); }