avro.shaded.com.google.common.collect.ImmutableMap Java Examples
The following examples show how to use
avro.shaded.com.google.common.collect.ImmutableMap.
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: ConfigStoreBasedPolicyTest.java From incubator-gobblin with Apache License 2.0 | 6 votes |
@Test public void test() throws Exception { URL prefix = getClass().getResource("/configStore"); Config config = ConfigFactory.parseMap(ImmutableMap.of( ConfigClientBasedPolicyFactory.CONFIG_KEY_URI_PREFIX_KEY, "simple-" + prefix.toString() )); SharedResourcesBroker<ThrottlingServerScopes> broker = SharedResourcesBrokerFactory.createDefaultTopLevelBroker( ConfigFactory.empty(), ThrottlingServerScopes.GLOBAL.defaultScopeInstance()); ConfigClientBasedPolicyFactory policyFactory = new ConfigClientBasedPolicyFactory(); ThrottlingPolicy policy = policyFactory.createPolicy(new SharedLimiterKey("ConfigBasedPolicyTest/resource1"), broker, config); Assert.assertEquals(policy.getClass(), QPSPolicy.class); Assert.assertEquals(((QPSPolicy) policy).getQps(), 100); policy = policyFactory.createPolicy(new SharedLimiterKey("ConfigBasedPolicyTest/resource2"), broker, config); Assert.assertEquals(policy.getClass(), CountBasedPolicy.class); Assert.assertEquals(((CountBasedPolicy) policy).getCount(), 50); }
Example #2
Source File: TestHadoopConfigLoader.java From incubator-gobblin with Apache License 2.0 | 6 votes |
@Test public void testOverride() { Config testConfig = ConfigFactory.parseMap(ImmutableMap.<String, Object>builder() .put("c.d", "1") .put("e.f", "2") .put("hadoop-inject.a.b.c.ROOT", "2") .put("hadoop-inject.a.b.c.d", "3") .put("hadoop-inject.e.f", "4") .build()); HadoopConfigLoader configLoader = new HadoopConfigLoader(testConfig); Configuration conf1 = configLoader.getConf(); Assert.assertEquals(conf1.get("a.b.c"), "2"); Assert.assertEquals(conf1.get("a.b.c.d"), "3"); Assert.assertEquals(conf1.get("e.f"), "4"); conf1.set("e.f", "5"); Assert.assertEquals(conf1.get("e.f"), "5"); Configuration conf2 = configLoader.getConf(); Assert.assertEquals(conf2.get("a.b.c"), "2"); Assert.assertEquals(conf2.get("a.b.c.d"), "3"); Assert.assertEquals(conf2.get("e.f"), "4"); }
Example #3
Source File: InfoController.java From data-highway with Apache License 2.0 | 5 votes |
@GetMapping("/paver/v1/userinfo") public Map<String, Object> home(Principal user) { UsernamePasswordAuthenticationToken token = (UsernamePasswordAuthenticationToken) user; return ImmutableMap .<String, Object> builder() .put("username", token.getName()) .put("authorities", token.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(toList())) .build(); }
Example #4
Source File: TestHadoopKerberosKeytabAuthenticationPlugin.java From incubator-gobblin with Apache License 2.0 | 5 votes |
@Test public void testConstructor() { final Config testConfig = ConfigFactory.parseMap(ImmutableMap.<String, Object>builder() .put("hadoop-inject.hadoop.security.authentication", "simple") .put("gobblin.instance.hadoop.loginUser", "foo") .put("gobblin.instance.hadoop.loginUserKeytabFile", "/tmp/bar") .build()); GobblinInstanceDriver instance = Mockito.mock(GobblinInstanceDriver.class); Mockito.when(instance.getSysConfig()).thenReturn(DefaultConfigurableImpl.createFromConfig(testConfig)); HadoopKerberosKeytabAuthenticationPlugin plugin = (HadoopKerberosKeytabAuthenticationPlugin) (new HadoopKerberosKeytabAuthenticationPlugin.ConfigBasedFactory()).createPlugin(instance); Assert.assertEquals(plugin.getLoginUser(), "foo"); Assert.assertEquals(plugin.getLoginUserKeytabFile(), "/tmp/bar"); Assert.assertEquals(plugin.getHadoopConf().get("hadoop.security.authentication"), "simple"); }
Example #5
Source File: TestHadoopKerberosKeytabAuthenticationPlugin.java From incubator-gobblin with Apache License 2.0 | 5 votes |
@Test public void testConfigConstructor() { final Config testConfig = ConfigFactory.parseMap(ImmutableMap.<String, Object>builder() .put("hadoop-inject.hadoop.security.authentication", "simple") .put("gobblin.instance.hadoop.loginUser", "foo") .put("gobblin.instance.hadoop.loginUserKeytabFile", "/tmp/bar") .build()); HadoopKerberosKeytabAuthenticationPlugin plugin = (HadoopKerberosKeytabAuthenticationPlugin) (new HadoopKerberosKeytabAuthenticationPlugin.ConfigBasedFactory()).createPlugin(testConfig); Assert.assertEquals(plugin.getLoginUser(), "foo"); Assert.assertEquals(plugin.getLoginUserKeytabFile(), "/tmp/bar"); Assert.assertEquals(plugin.getHadoopConf().get("hadoop.security.authentication"), "simple"); }
Example #6
Source File: TestHadoopKerberosKeytabAuthenticationPlugin.java From incubator-gobblin with Apache License 2.0 | 5 votes |
@Test public void testMissingOptions() { final Config testConfig1 = ConfigFactory.parseMap(ImmutableMap.<String, Object>builder() .put("hadoop-inject.hadoop.security.authentication", "simple") .put("hadoop.loginUser", "foo") .put("gobblin.instance.hadoop.loginUserKeytabFile", "/tmp/bar") .build()); final GobblinInstanceDriver instance1 = Mockito.mock(GobblinInstanceDriver.class); Mockito.when(instance1.getSysConfig()).thenReturn(DefaultConfigurableImpl.createFromConfig(testConfig1)); Assert.assertThrows(new ThrowingRunnable() { @Override public void run() throws Throwable { (new HadoopKerberosKeytabAuthenticationPlugin.ConfigBasedFactory()).createPlugin(instance1); } }); final Config testConfig2 = ConfigFactory.parseMap(ImmutableMap.<String, Object>builder() .put("hadoop-inject.hadoop.security.authentication", "simple") .put("gobblin.instance.hadoop.loginUser", "foo") .put("hadoop.loginUserKeytabFile", "/tmp/bar") .build()); final GobblinInstanceDriver instance2 = Mockito.mock(GobblinInstanceDriver.class); Mockito.when(instance1.getSysConfig()).thenReturn(DefaultConfigurableImpl.createFromConfig(testConfig2)); Assert.assertThrows(new ThrowingRunnable() { @Override public void run() throws Throwable { (new HadoopKerberosKeytabAuthenticationPlugin.ConfigBasedFactory()).createPlugin(instance2); } }); }
Example #7
Source File: ConfigIT.java From digdag with Apache License 2.0 | 4 votes |
@Test public void verifyPrecedenceWithDefaultConfigFile() throws Exception { Path projectDir = folder.newFolder().toPath(); addWorkflow(projectDir, "acceptance/params.dig"); Path home = folder.newFolder().toPath().resolve("home"); Path configFile = home.resolve(".config").resolve("digdag").resolve("config"); Files.createDirectories(configFile.getParent()); TestUtils.fakeHome(home.toString(), () -> { Files.write(configFile, asList( "params.param1=defaultConfigValue1", "params.param2=defaultConfigValue2", "params.param3=defaultConfigValue3", "params.param4=defaultConfigValue4" )); Map<String, String> env = ImmutableMap.of( "DIGDAG_CONFIG", Joiner.on('\n').join( "params.param2=envConfigValue2", "params.param3=envConfigValue3", "params.param4=envConfigValue4" ) ); TestUtils.withSystemProperties(ImmutableMap.of( "params.param3", "systemPropValue3", "params.param4", "systemPropValue4"), () -> { main(env, "run", "-o", folder.newFolder().getAbsolutePath(), "--project", projectDir.toString(), "-p", "param4=commandLinePropValue4", "params.dig"); }); }); assertThat(Files.readAllLines(projectDir.resolve("param1.out")), contains("defaultConfigValue1")); assertThat(Files.readAllLines(projectDir.resolve("param2.out")), contains("envConfigValue2")); assertThat(Files.readAllLines(projectDir.resolve("param3.out")), contains("systemPropValue3")); assertThat(Files.readAllLines(projectDir.resolve("param4.out")), contains("commandLinePropValue4")); }
Example #8
Source File: ConfigIT.java From digdag with Apache License 2.0 | 4 votes |
@Test public void verifyPrecedenceWithExplicitConfigFile() throws Exception { Path projectDir = folder.newFolder().toPath(); addWorkflow(projectDir, "acceptance/params.dig"); Path home = folder.newFolder().toPath().resolve("home"); Path defaultConfigFile = home.resolve(".config").resolve("digdag").resolve("config"); Files.createDirectories(defaultConfigFile.getParent()); Path explicitConfig = folder.newFolder().toPath().resolve("explicit-config"); Files.write(explicitConfig, asList( "params.param3=explicitConfigValue3", "params.param4=explicitConfigValue4" )); TestUtils.fakeHome(home.toString(), () -> { Files.write(defaultConfigFile, asList( "params.param1=defaultConfigValue1", "params.param2=defaultConfigValue2", "params.param3=defaultConfigValue3", "params.param4=defaultConfigValue4" )); Map<String, String> env = ImmutableMap.of( "DIGDAG_CONFIG", Joiner.on('\n').join( "params.param1=envConfigValue1", "params.param2=envConfigValue2", "params.param3=envConfigValue3", "params.param4=envConfigValue4" ) ); TestUtils.withSystemProperties(ImmutableMap.of( "params.param2", "systemPropValue2", "params.param3", "systemPropValue3", "params.param4", "systemPropValue4"), () -> { main(env, "run", "-o", folder.newFolder().getAbsolutePath(), "--config", explicitConfig.toString(), "--project", projectDir.toString(), "-p", "param4=commandLinePropValue4", "params.dig"); }); }); assertThat(Files.readAllLines(projectDir.resolve("param1.out")), contains("envConfigValue1")); assertThat(Files.readAllLines(projectDir.resolve("param2.out")), contains("systemPropValue2")); assertThat(Files.readAllLines(projectDir.resolve("param3.out")), contains("explicitConfigValue3")); assertThat(Files.readAllLines(projectDir.resolve("param4.out")), contains("commandLinePropValue4")); }
Example #9
Source File: LimiterServerResourceTest.java From incubator-gobblin with Apache License 2.0 | 4 votes |
@Test public void testSleepOnClientDelegation() { ThrottlingPolicyFactory factory = new ThrottlingPolicyFactory(); SharedLimiterKey res1key = new SharedLimiterKey("res1"); Map<String, String> configMap = ImmutableMap.<String, String>builder() .put(BrokerConfigurationKeyGenerator.generateKey(factory, res1key, null, ThrottlingPolicyFactory.POLICY_KEY), TestWaitPolicy.class.getName()) .build(); ThrottlingGuiceServletConfig guiceServletConfig = new ThrottlingGuiceServletConfig(); Sleeper.MockSleeper sleeper = guiceServletConfig.mockSleeper(); guiceServletConfig.initialize(ConfigFactory.parseMap(configMap)); Injector injector = guiceServletConfig.getInjector(); LimiterServerResource limiterServer = injector.getInstance(LimiterServerResource.class); PermitRequest request = new PermitRequest(); request.setPermits(5); request.setResource(res1key.getResourceLimitedPath()); request.setVersion(ThrottlingProtocolVersion.BASE.ordinal()); // policy does not require sleep, verify no sleep happened or is requested from client PermitAllocation allocation = limiterServer.getSync(new ComplexResourceKey<>(request, new EmptyRecord())); Assert.assertEquals((long) allocation.getPermits(), 5); Assert.assertEquals((long) allocation.getWaitForPermitUseMillis(GetMode.DEFAULT), 0); Assert.assertTrue(sleeper.getRequestedSleeps().isEmpty()); // policy requests a sleep of 10 millis, using BASE protocol version, verify server executes the sleep request.setPermits(20); request.setVersion(ThrottlingProtocolVersion.BASE.ordinal()); allocation = limiterServer.getSync(new ComplexResourceKey<>(request, new EmptyRecord())); Assert.assertEquals((long) allocation.getPermits(), 20); Assert.assertEquals((long) allocation.getWaitForPermitUseMillis(GetMode.DEFAULT), 0); Assert.assertEquals((long) sleeper.getRequestedSleeps().peek(), 10); sleeper.reset(); // policy requests a sleep of 10 millis, using WAIT_ON_CLIENT protocol version, verify server delegates sleep to client request.setVersion(ThrottlingProtocolVersion.WAIT_ON_CLIENT.ordinal()); request.setPermits(20); allocation = limiterServer.getSync(new ComplexResourceKey<>(request, new EmptyRecord())); Assert.assertEquals((long) allocation.getPermits(), 20); Assert.assertEquals((long) allocation.getWaitForPermitUseMillis(GetMode.DEFAULT), 10); Assert.assertTrue(sleeper.getRequestedSleeps().isEmpty()); }
Example #10
Source File: ImmutableComputableGraph.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 3 votes |
/** * Nullifies the cached value of a node (both computable and primitive) * * @param nodeKey key of the node to be nullified * @return a new instance of {@link ImmutableComputableGraph} * @throws IllegalArgumentException if the node does not exist */ public ImmutableComputableGraph nullifyNode(@Nonnull final String nodeKey) throws IllegalArgumentException { assertNodeExists(nodeKey); CacheNode oldNode = nodesMap.get(nodeKey); return duplicateWithUpdatedNodes(ImmutableMap.of(nodeKey, oldNode.duplicateWithUpdatedValue(null))); }