com.google.common.annotations.VisibleForTesting Java Examples
The following examples show how to use
com.google.common.annotations.VisibleForTesting.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProtocolNegotiators.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@VisibleForTesting HostPort parseAuthority(String authority) { URI uri = GrpcUtil.authorityToUri(Preconditions.checkNotNull(authority, "authority")); String host; int port; if (uri.getHost() != null) { host = uri.getHost(); port = uri.getPort(); } else { /* * Implementation note: We pick -1 as the port here rather than deriving it from the * original socket address. The SSL engine doens't use this port number when contacting the * remote server, but rather it is used for other things like SSL Session caching. When an * invalid authority is provided (like "bad_cert"), picking the original port and passing it * in would mean that the port might used under the assumption that it was correct. By * using -1 here, it forces the SSL implementation to treat it as invalid. */ host = authority; port = -1; } return new HostPort(host, port); }
Example #2
Source File: SimplifyExpressions.java From presto with Apache License 2.0 | 6 votes |
@VisibleForTesting static Expression rewrite(Expression expression, Session session, SymbolAllocator symbolAllocator, Metadata metadata, LiteralEncoder literalEncoder, TypeAnalyzer typeAnalyzer) { requireNonNull(metadata, "metadata is null"); requireNonNull(typeAnalyzer, "typeAnalyzer is null"); if (expression instanceof SymbolReference) { return expression; } Map<NodeRef<Expression>, Type> expressionTypes = typeAnalyzer.getTypes(session, symbolAllocator.getTypes(), expression); expression = pushDownNegations(metadata, expression, expressionTypes); expression = extractCommonPredicates(metadata, expression); expressionTypes = typeAnalyzer.getTypes(session, symbolAllocator.getTypes(), expression); ExpressionInterpreter interpreter = ExpressionInterpreter.expressionOptimizer(expression, metadata, session, expressionTypes); Object optimized = interpreter.optimize(NoOpSymbolResolver.INSTANCE); return literalEncoder.toExpression(optimized, expressionTypes.get(NodeRef.of(expression))); }
Example #3
Source File: ElasticsearchClient.java From presto with Apache License 2.0 | 6 votes |
@VisibleForTesting static Optional<String> extractAddress(String address) { Matcher matcher = ADDRESS_PATTERN.matcher(address); if (!matcher.matches()) { return Optional.empty(); } String cname = matcher.group("cname"); String ip = matcher.group("ip"); String port = matcher.group("port"); if (cname != null) { return Optional.of(cname + ":" + port); } return Optional.of(ip + ":" + port); }
Example #4
Source File: RecordingHiveMetastore.java From presto with Apache License 2.0 | 6 votes |
@VisibleForTesting void loadRecording() throws IOException { Recording recording = RECORDING_CODEC.fromJson(readAllBytes(recordingPath)); allDatabases = recording.getAllDatabases(); allRoles = recording.getAllRoles(); databaseCache.putAll(toMap(recording.getDatabases())); tableCache.putAll(toMap(recording.getTables())); supportedColumnStatisticsCache.putAll(toMap(recording.getSupportedColumnStatistics())); tableStatisticsCache.putAll(toMap(recording.getTableStatistics())); partitionStatisticsCache.putAll(toMap(recording.getPartitionStatistics())); allTablesCache.putAll(toMap(recording.getAllTables())); tablesWithParameterCache.putAll(toMap(recording.getTablesWithParameter())); allViewsCache.putAll(toMap(recording.getAllViews())); partitionCache.putAll(toMap(recording.getPartitions())); partitionNamesCache.putAll(toMap(recording.getPartitionNames())); partitionNamesByPartsCache.putAll(toMap(recording.getPartitionNamesByParts())); partitionsByNamesCache.putAll(toMap(recording.getPartitionsByNames())); tablePrivilegesCache.putAll(toMap(recording.getTablePrivileges())); roleGrantsCache.putAll(toMap(recording.getRoleGrants())); grantedPrincipalsCache.putAll(toMap(recording.getGrantedPrincipals())); }
Example #5
Source File: Driver.java From presto with Apache License 2.0 | 5 votes |
@VisibleForTesting public static Driver createDriver(DriverContext driverContext, Operator firstOperator, Operator... otherOperators) { requireNonNull(driverContext, "driverContext is null"); requireNonNull(firstOperator, "firstOperator is null"); requireNonNull(otherOperators, "otherOperators is null"); ImmutableList<Operator> operators = ImmutableList.<Operator>builder() .add(firstOperator) .add(otherOperators) .build(); return createDriver(driverContext, operators); }
Example #6
Source File: AttackStylesPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe @VisibleForTesting void onConfigChanged(ConfigChanged event) { if (event.getGroup().equals("attackIndicator")) { boolean enabled = Boolean.TRUE.toString().equals(event.getNewValue()); switch (event.getKey()) { case "warnForDefensive": updateWarnedSkills(enabled, Skill.DEFENCE); break; case "warnForAttack": updateWarnedSkills(enabled, Skill.ATTACK); break; case "warnForStrength": updateWarnedSkills(enabled, Skill.STRENGTH); break; case "warnForRanged": updateWarnedSkills(enabled, Skill.RANGED); break; case "warnForMagic": updateWarnedSkills(enabled, Skill.MAGIC); break; case "removeWarnedStyles": hideWarnedStyles(enabled); break; } processWidgets(); } }
Example #7
Source File: AutoConfiguredLoadBalancerFactory.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
/** * Picks a load balancer based on given criteria. In order of preference: * * <ol> * <li>User provided lb on the channel. This is a degenerate case and not handled here.</li> * <li>"grpclb" if any gRPC LB balancer addresses are present</li> * <li>The policy picked by the service config</li> * <li>"pick_first" if the service config choice does not specify</li> * </ol> * * @param servers The list of servers reported * @param config the service config object * @return the new load balancer factory, never null */ @VisibleForTesting static LoadBalancerProvider decideLoadBalancerProvider( List<EquivalentAddressGroup> servers, @Nullable Map<String, Object> config) throws PolicyNotFoundException { // Check for balancer addresses boolean haveBalancerAddress = false; for (EquivalentAddressGroup s : servers) { if (s.getAttributes().get(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY) != null) { haveBalancerAddress = true; break; } } if (haveBalancerAddress) { return getProviderOrThrow("grpclb", "NameResolver has returned balancer addresses"); } String serviceConfigChoiceBalancingPolicy = null; if (config != null) { serviceConfigChoiceBalancingPolicy = ServiceConfigUtil.getLoadBalancingPolicyFromServiceConfig(config); if (serviceConfigChoiceBalancingPolicy != null) { // Handle ASCII specifically rather than relying on the implicit default locale of the str return getProviderOrThrow( Ascii.toLowerCase(serviceConfigChoiceBalancingPolicy), "service-config specifies load-balancing policy"); } } return getProviderOrThrow(DEFAULT_POLICY, "Using default policy"); }
Example #8
Source File: HFileOutputFormat3.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
/** * Runs inside the task to deserialize column family to compression algorithm * map from the configuration. * * @param conf to read the serialized values from * @return a map from column family to the configured compression algorithm */ @VisibleForTesting static Map<byte[], Algorithm> createFamilyCompressionMap(Configuration conf) { Map<byte[], String> stringMap = createFamilyConfValueMap(conf, COMPRESSION_FAMILIES_CONF_KEY); Map<byte[], Algorithm> compressionMap = new TreeMap<byte[], Algorithm>(Bytes.BYTES_COMPARATOR); for (Map.Entry<byte[], String> e : stringMap.entrySet()) { Algorithm algorithm = AbstractHFileWriter.compressionByName(e.getValue()); compressionMap.put(e.getKey(), algorithm); } return compressionMap; }
Example #9
Source File: GrpcClient.java From cloud-spanner-r2dbc with Apache License 2.0 | 5 votes |
@VisibleForTesting GrpcClient(SpannerStub spanner, DatabaseAdminStub databaseAdmin, OperationsStub operations) { this.spanner = spanner; this.databaseAdmin = databaseAdmin; this.operations = operations; this.channel = null; }
Example #10
Source File: HFileOutputFormat3.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
/** * Runs inside the task to deserialize column family to bloom filter type * map from the configuration. * * @param conf to read the serialized values from * @return a map from column family to the the configured bloom filter type */ @VisibleForTesting static Map<byte[], BloomType> createFamilyBloomTypeMap(Configuration conf) { Map<byte[], String> stringMap = createFamilyConfValueMap(conf, BLOOM_TYPE_FAMILIES_CONF_KEY); Map<byte[], BloomType> bloomTypeMap = new TreeMap<byte[], BloomType>(Bytes.BYTES_COMPARATOR); for (Map.Entry<byte[], String> e : stringMap.entrySet()) { BloomType bloomType = BloomType.valueOf(e.getValue()); bloomTypeMap.put(e.getKey(), bloomType); } return bloomTypeMap; }
Example #11
Source File: TableFinishOperator.java From presto with Apache License 2.0 | 5 votes |
@VisibleForTesting TableFinishInfo getInfo() { return new TableFinishInfo( outputMetadata, new Duration(statisticsTiming.getWallNanos(), NANOSECONDS).convertToMostSuccinctTimeUnit(), new Duration(statisticsTiming.getCpuNanos(), NANOSECONDS).convertToMostSuccinctTimeUnit()); }
Example #12
Source File: ConfigFileServerSet.java From singer with Apache License 2.0 | 5 votes |
/** * Internal constructor. This is provided for use by unit test. * * @param configFileWatcher ConfigFileWatcher instance to use. * @param serverSetFilePath Path the server set file on local disk. This is expected to contain a list of host:port * pairs, one per line. An external daemon will be responsible for keeping this in sync with the actual server set in * ZooKeeper. */ @VisibleForTesting ConfigFileServerSet(ConfigFileWatcher configFileWatcher, String serverSetFilePath) { this.serverSetFilePath = MorePreconditions.checkNotBlank(serverSetFilePath); this.configFileWatcher = Preconditions.checkNotNull(configFileWatcher); File file = new File(serverSetFilePath); if (!file.exists()) { String message = String.format("Server set file: %s doesn't exist", serverSetFilePath); throw new IllegalArgumentException(message); } }
Example #13
Source File: ContainerStateMachine.java From hadoop-ozone with Apache License 2.0 | 5 votes |
@VisibleForTesting public void buildMissingContainerSet(File snapshotFile) throws IOException { // initialize the dispatcher with snapshot so that it build the missing // container list try (FileInputStream fin = new FileInputStream(snapshotFile)) { ContainerProtos.Container2BCSIDMapProto proto = ContainerProtos.Container2BCSIDMapProto .parseFrom(fin); // read the created containers list from the snapshot file and add it to // the container2BCSIDMap here. // container2BCSIDMap will further grow as and when containers get created container2BCSIDMap.putAll(proto.getContainer2BCSIDMap()); dispatcher.buildMissingContainerSetAndValidate(container2BCSIDMap); } }
Example #14
Source File: TestingWarningCollector.java From presto with Apache License 2.0 | 5 votes |
@VisibleForTesting public static PrestoWarning createTestWarning(int code) { // format string below is a hack to construct a vendor specific SQLState value // 01 is the class of warning code and 5 is the first allowed vendor defined prefix character // See the SQL Standard ISO_IEC_9075-2E_2016 24.1: SQLState for more information return new PrestoWarning(new WarningCode(code, format("015%02d", code % 100)), "Test warning " + code); }
Example #15
Source File: KeyOutputStream.java From hadoop-ozone with Apache License 2.0 | 5 votes |
/** * A constructor for testing purpose only. */ @VisibleForTesting public KeyOutputStream() { closed = false; this.retryPolicyMap = HddsClientUtils.getExceptionList() .stream() .collect(Collectors.toMap(Function.identity(), e -> RetryPolicies.TRY_ONCE_THEN_FAIL)); retryCount = 0; offset = 0; blockOutputStreamEntryPool = new BlockOutputStreamEntryPool(); }
Example #16
Source File: HashAggregationOperator.java From presto with Apache License 2.0 | 5 votes |
@VisibleForTesting HashAggregationOperatorFactory( int operatorId, PlanNodeId planNodeId, List<? extends Type> groupByTypes, List<Integer> groupByChannels, List<Integer> globalAggregationGroupIds, Step step, boolean produceDefaultOutput, List<AccumulatorFactory> accumulatorFactories, Optional<Integer> hashChannel, Optional<Integer> groupIdChannel, int expectedGroups, Optional<DataSize> maxPartialMemory, boolean spillEnabled, DataSize memoryLimitForMerge, DataSize memoryLimitForMergeWithMemory, SpillerFactory spillerFactory, JoinCompiler joinCompiler, boolean useSystemMemory) { this.operatorId = operatorId; this.planNodeId = requireNonNull(planNodeId, "planNodeId is null"); this.hashChannel = requireNonNull(hashChannel, "hashChannel is null"); this.groupIdChannel = requireNonNull(groupIdChannel, "groupIdChannel is null"); this.groupByTypes = ImmutableList.copyOf(groupByTypes); this.groupByChannels = ImmutableList.copyOf(groupByChannels); this.globalAggregationGroupIds = ImmutableList.copyOf(globalAggregationGroupIds); this.step = step; this.produceDefaultOutput = produceDefaultOutput; this.accumulatorFactories = ImmutableList.copyOf(accumulatorFactories); this.expectedGroups = expectedGroups; this.maxPartialMemory = requireNonNull(maxPartialMemory, "maxPartialMemory is null"); this.spillEnabled = spillEnabled; this.memoryLimitForMerge = requireNonNull(memoryLimitForMerge, "memoryLimitForMerge is null"); this.memoryLimitForMergeWithMemory = requireNonNull(memoryLimitForMergeWithMemory, "memoryLimitForMergeWithMemory is null"); this.spillerFactory = requireNonNull(spillerFactory, "spillerFactory is null"); this.joinCompiler = requireNonNull(joinCompiler, "joinCompiler is null"); this.useSystemMemory = useSystemMemory; }
Example #17
Source File: OzoneManagerServiceProviderImpl.java From hadoop-ozone with Apache License 2.0 | 5 votes |
/** * Get Delta updates from OM through RPC call and apply to local OM DB as * well as accumulate in a buffer. * @param fromSequenceNumber from sequence number to request from. * @param omdbUpdatesHandler OM DB updates handler to buffer updates. * @throws IOException when OM RPC request fails. * @throws RocksDBException when writing to RocksDB fails. */ @VisibleForTesting void getAndApplyDeltaUpdatesFromOM( long fromSequenceNumber, OMDBUpdatesHandler omdbUpdatesHandler) throws IOException, RocksDBException { DBUpdatesRequest dbUpdatesRequest = DBUpdatesRequest.newBuilder() .setSequenceNumber(fromSequenceNumber).build(); DBUpdates dbUpdates = ozoneManagerClient.getDBUpdates(dbUpdatesRequest); if (null != dbUpdates) { RDBStore rocksDBStore = (RDBStore) omMetadataManager.getStore(); RocksDB rocksDB = rocksDBStore.getDb(); int numUpdates = dbUpdates.getData().size(); LOG.info("Number of updates received from OM : {}", numUpdates); if (numUpdates > 0) { metrics.incrNumUpdatesInDeltaTotal(numUpdates); } for (byte[] data : dbUpdates.getData()) { try (WriteBatch writeBatch = new WriteBatch(data)) { writeBatch.iterate(omdbUpdatesHandler); try (RDBBatchOperation rdbBatchOperation = new RDBBatchOperation(writeBatch)) { try (WriteOptions wOpts = new WriteOptions()) { rdbBatchOperation.commit(rocksDB, wOpts); } } } } } }
Example #18
Source File: PasswordStore.java From presto with Apache License 2.0 | 5 votes |
@VisibleForTesting public PasswordStore(List<String> lines, int cacheMaxSize) { credentials = loadPasswordFile(lines); cache = CacheBuilder.newBuilder() .maximumSize(cacheMaxSize) .build(CacheLoader.from(this::matches)); }
Example #19
Source File: TransactionRequestAssembler.java From java-sdk with Apache License 2.0 | 5 votes |
@VisibleForTesting NewOrderMessage createNewOrderMessage( com.binance.dex.api.client.domain.broadcast.NewOrder newOrder) { return NewOrderMessage.newBuilder() .setId(generateOrderId()) .setOrderType(newOrder.getOrderType()) .setPrice(newOrder.getPrice()) .setQuantity(newOrder.getQuantity()) .setSender(wallet.getAddress()) .setSide(newOrder.getSide()) .setSymbol(newOrder.getSymbol()) .setTimeInForce(newOrder.getTimeInForce()) .build(); }
Example #20
Source File: OzoneManager.java From hadoop-ozone with Apache License 2.0 | 5 votes |
@VisibleForTesting public LifeCycle.State getOmRatisServerState() { if (omRatisServer == null) { return null; } else { return omRatisServer.getServerState(); } }
Example #21
Source File: FileSingleStreamSpillerFactory.java From presto with Apache License 2.0 | 5 votes |
@VisibleForTesting public FileSingleStreamSpillerFactory( ListeningExecutorService executor, BlockEncodingSerde blockEncodingSerde, SpillerStats spillerStats, List<Path> spillPaths, double maxUsedSpaceThreshold, boolean spillCompressionEnabled, boolean spillEncryptionEnabled) { this.serdeFactory = new PagesSerdeFactory(blockEncodingSerde, spillCompressionEnabled); this.executor = requireNonNull(executor, "executor is null"); this.spillerStats = requireNonNull(spillerStats, "spillerStats cannot be null"); requireNonNull(spillPaths, "spillPaths is null"); this.spillPaths = ImmutableList.copyOf(spillPaths); spillPaths.forEach(path -> { try { createDirectories(path); } catch (IOException e) { throw new IllegalArgumentException(format("could not create spill path %s; adjust %s config property or filesystem permissions", path, SPILLER_SPILL_PATH), e); } if (!isAccessible(path)) { throw new IllegalArgumentException(format("spill path %s is not accessible, it must be +rwx; adjust %s config property or filesystem permissions", path, SPILLER_SPILL_PATH)); } }); this.maxUsedSpaceThreshold = maxUsedSpaceThreshold; this.spillEncryptionEnabled = spillEncryptionEnabled; this.roundRobinIndex = 0; this.spillPathHealthCache = CacheBuilder.newBuilder() .expireAfterWrite(SPILL_PATH_HEALTH_EXPIRY_INTERVAL) .build(CacheLoader.from(path -> isAccessible(path) && isSeeminglyHealthy(path))); }
Example #22
Source File: AccessControlManager.java From presto with Apache License 2.0 | 5 votes |
@VisibleForTesting protected void setSystemAccessControl(String name, Map<String, String> properties) { requireNonNull(name, "name is null"); requireNonNull(properties, "properties is null"); checkState(systemAccessControlLoading.compareAndSet(false, true), "System access control already initialized"); SystemAccessControlFactory systemAccessControlFactory = systemAccessControlFactories.get(name); checkState(systemAccessControlFactory != null, "Access control '%s' is not registered", name); SystemAccessControl systemAccessControl = systemAccessControlFactory.create(ImmutableMap.copyOf(properties)); this.systemAccessControls.set(ImmutableList.of(systemAccessControl)); }
Example #23
Source File: StreamingContainerManager.java From Bats with Apache License 2.0 | 5 votes |
@VisibleForTesting protected Collection<Pair<Long, Map<String, Object>>> getLogicalMetrics(String operatorName) { if (logicalMetrics.get(operatorName) != null) { return Collections.unmodifiableCollection(logicalMetrics.get(operatorName)); } return null; }
Example #24
Source File: LocalFileCredentialFactory.java From connector-sdk with Apache License 2.0 | 4 votes |
@VisibleForTesting static void setCredentialHelper(CredentialHelper helper) { credentialHelper = helper; }
Example #25
Source File: PartitionedOutputBuffer.java From presto with Apache License 2.0 | 4 votes |
@VisibleForTesting OutputBufferMemoryManager getMemoryManager() { return memoryManager; }
Example #26
Source File: StressTestClient.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
@VisibleForTesting boolean useTls() { return useTls; }
Example #27
Source File: OMKeyRenameResponse.java From hadoop-ozone with Apache License 2.0 | 4 votes |
@VisibleForTesting public boolean deleteFromKeyOnly() { return toKeyName == null && fromKeyName != null; }
Example #28
Source File: ScreenshotPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@VisibleForTesting int getClueNumber() { return clueNumber; }
Example #29
Source File: BlockDeletingServiceTestImpl.java From hadoop-ozone with Apache License 2.0 | 4 votes |
@VisibleForTesting public boolean isStarted() { return latch != null && testingThread.isAlive(); }
Example #30
Source File: MutableVolumeSet.java From hadoop-ozone with Apache License 2.0 | 4 votes |
@Override @VisibleForTesting public List<HddsVolume> getVolumesList() { return ImmutableList.copyOf(volumeMap.values()); }