本文整理汇总了Java中scala.collection.immutable.Map类的典型用法代码示例。如果您正苦于以下问题:Java Map类的具体用法?Java Map怎么用?Java Map使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Map类属于scala.collection.immutable包,在下文中一共展示了Map类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLoadInfoSparkNoConfig
import scala.collection.immutable.Map; //导入依赖的package包/类
@Test
public void testLoadInfoSparkNoConfig() {
Map<String,String> properties = new HashMap<String,String>();
AppResult result = new AppResult();
HadoopApplicationData data = new SparkApplicationData("application_5678",
properties,
new ApplicationInfoImpl("", "", new Vector<ApplicationAttemptInfoImpl>(0,1,0)),
new Vector<JobData>(0,1,0),
new Vector<StageData>(0,1,0),
new Vector<ExecutorSummary>(0,1,0));
// test to make sure loadInfo does not throw exception if properties are not defined
InfoExtractor.loadInfo(result, data);
assertTrue(result.jobDefId.isEmpty());
assertTrue(result.jobExecId.isEmpty());
assertTrue(result.flowDefId.isEmpty());
assertTrue(result.flowExecId.isEmpty());
}
示例2: createRelation
import scala.collection.immutable.Map; //导入依赖的package包/类
@Override
public BaseRelation createRelation(SQLContext arg0, Map<String, String> arg1) {
log.debug("-> createRelation()");
java.util.Map<String, String> javaMap = scala.collection.JavaConverters
.mapAsJavaMapConverter(arg1).asJava();
SubStringCounterRelation br = new SubStringCounterRelation();
br.setSqlContext(arg0);
for (java.util.Map.Entry<String, String> entry : javaMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
log.debug("[{}] --> [{}]", key, value);
if (key.compareTo(K.PATH) == 0) {
br.setFilename(value);
} else if (key.startsWith(K.COUNT)) {
br.addCriteria(value);
}
}
return br;
}
示例3: read
import scala.collection.immutable.Map; //导入依赖的package包/类
@Override
public Option<Model> read(Class<?> modelClass, Map<String, String> typeMap) {
final Option<Model> modelOption = super.read(modelClass, typeMap);
// Look for public properties
java.util.Map<String, ApiControllerUtilsServiceImpl.SerializationEntry> entries = ApiControllerUtilsServiceImpl.getSerializationEntries(modelClass,
null);
// Remove all properties which are not public
if (!modelOption.isEmpty()) {
Iterator<String> keysIterator = modelOption.get().properties().keysIterator();
while (keysIterator.hasNext()) {
String propertyName = keysIterator.next();
if (!entries.containsKey(propertyName)) {
modelOption.get().properties().remove(propertyName);
if (log.isDebugEnabled()) {
log.debug("Successfully hidden API model property '" + propertyName + "'");
}
}
}
}
return modelOption;
}
示例4: testAddAclsForNonExistentRole
import scala.collection.immutable.Map; //导入依赖的package包/类
@Test
public void testAddAclsForNonExistentRole() {
sentryKafkaAuthorizer = new SentryKafkaAuthorizer();
java.util.Map<String, String> configs = new HashMap<>();
configs.put(KafkaAuthConf.SENTRY_KAFKA_SITE_URL, "file://" + sentrySitePath.getAbsolutePath());
sentryKafkaAuthorizer.configure(configs);
final String role1 = "role1";
Set<Acl> acls = new HashSet<>();
final Acl acl = new Acl(new KafkaPrincipal("role", role1),
Allow$.MODULE$,
"127.0.0.1",
Operation$.MODULE$.fromString("READ"));
acls.add(acl);
scala.collection.immutable.Set<Acl> aclsScala = scala.collection.JavaConversions.asScalaSet(acls).toSet();
Resource resource = new Resource(ResourceType$.MODULE$.fromString("TOPIC"), "test-topic");
try {
sentryKafkaAuthorizer.addAcls(aclsScala, resource);
} catch (Exception ex) {
assertCausedMessage(ex, "Can not add Acl for non-existent Role: role1");
}
}
示例5: configure
import scala.collection.immutable.Map; //导入依赖的package包/类
@Override
public void configure(java.util.Map<String, ?> configs) {
final Object sentryKafkaSiteUrlConfig = configs.get(KafkaAuthConf.SENTRY_KAFKA_SITE_URL);
if (sentryKafkaSiteUrlConfig != null) {
this.sentry_site = sentryKafkaSiteUrlConfig.toString();
}
final Object kafkaSuperUsersConfig = configs.get(KafkaAuthConf.KAFKA_SUPER_USERS);
if (kafkaSuperUsersConfig != null) {
getSuperUsers(kafkaSuperUsersConfig.toString());
}
final Object kafkaServiceInstanceName = configs.get(KafkaAuthConf.KAFKA_SERVICE_INSTANCE_NAME);
if (kafkaServiceInstanceName != null) {
this.kafkaServiceInstanceName = kafkaServiceInstanceName.toString();
}
final Object kafkaServiceUserName = configs.get(KafkaAuthConf.KAFKA_SERVICE_USER_NAME);
if (kafkaServiceUserName != null) {
this.requestorName = kafkaServiceUserName.toString();
}
LOG.info("Configuring Sentry KafkaAuthorizer: " + sentry_site);
final KafkaAuthBindingSingleton instance = KafkaAuthBindingSingleton.getInstance();
instance.configure(this.kafkaServiceInstanceName, this.requestorName, sentry_site);
this.binding = instance.getAuthBinding();
}
示例6: getRoleToPrivileges
import scala.collection.immutable.Map; //导入依赖的package包/类
private java.util.Map<String, scala.collection.immutable.Set<TSentryPrivilege>> getRoleToPrivileges(final List<String> roles) {
final java.util.Map<String, scala.collection.immutable.Set<TSentryPrivilege>> rolePrivilegesMap = new HashMap<>();
execute(new Command<Void>() {
@Override
public Void run(SentryGenericServiceClient client) throws Exception {
for (String role : roles) {
final Set<TSentryPrivilege> rolePrivileges = client.listPrivilegesByRoleName(
requestorName, role, COMPONENT_NAME, instanceName);
final scala.collection.immutable.Set<TSentryPrivilege> rolePrivilegesScala =
scala.collection.JavaConverters.asScalaSetConverter(rolePrivileges).asScala().toSet();
rolePrivilegesMap.put(role, rolePrivilegesScala);
}
return null;
}
});
return rolePrivilegesMap;
}
示例7: read
import scala.collection.immutable.Map; //导入依赖的package包/类
@Override
public Option<Model> read(Class<?> cls, Map<String, String> typeMap) {
Schema schema = getSchema(cls);
if (schema == null) {
return Option.empty();
}
LinkedHashMap<String, ModelProperty> properties = new LinkedHashMap<>();
for (Schema.Field field : schema.getFields()) {
ModelProperty property = parseField(field);
if (property == null) {
LOGGER.debug(
"Omitted field {} of schema {} from swagger docs", field.name(), schema.getName());
} else {
properties.update(getFieldName(field), property);
}
}
return Option.apply(
new Model(
toName(cls),
toName(cls),
cls.getName(),
properties,
toDescriptionOpt(cls),
Option.<String>empty(),
Option.<String>empty(),
JavaConversions.asScalaBuffer(Collections.<String>emptyList()).toList()));
}
示例8: testLoadInfoSpark
import scala.collection.immutable.Map; //导入依赖的package包/类
@Test
public void testLoadInfoSpark() {
final String JOB_DEF_URL = "https://grid.example.com:9000/manager?project=project-name&flow=flow-name&job=job-name";
final String JOB_EXEC_URL = "https://grid.example.com:9000/executor?execid=123456&job=job-name&attempt=0";
final String FLOW_DEF_URL = "https://grid.example.com:9000/manager?project=project-name&flow=flow-name";
final String FLOW_EXEC_URL = "https://grid.example.com:9000/executor?execid=123456";
final String JAVA_EXTRA_OPTIONS = "spark.driver.extraJavaOptions";
Map<String,String> properties = new HashMap<String,String>();
properties = properties.$plus(new Tuple2<String, String>(JAVA_EXTRA_OPTIONS, "-Dazkaban.link.workflow.url=" + FLOW_DEF_URL +
" -Dazkaban.link.job.url=" + JOB_DEF_URL +
" -Dazkaban.link.execution.url=" + FLOW_EXEC_URL +
" -Dazkaban.link.attempt.url=" + JOB_EXEC_URL));
AppResult result = new AppResult();
HadoopApplicationData data = new SparkApplicationData("application_5678",
properties,
new ApplicationInfoImpl("", "", new Vector<ApplicationAttemptInfoImpl>(0,1,0)),
new Vector<JobData>(0,1,0),
new Vector<StageData>(0,1,0),
new Vector<ExecutorSummary>(0,1,0));
InfoExtractor.loadInfo(result, data);
assertTrue(result.jobDefId.equals(JOB_DEF_URL));
assertTrue(result.jobExecId.equals(JOB_EXEC_URL));
assertTrue(result.flowDefId.equals(FLOW_DEF_URL));
assertTrue(result.flowExecId.equals(FLOW_EXEC_URL));
}
示例9: main
import scala.collection.immutable.Map; //导入依赖的package包/类
public static void main(String[] args) {
new MyJavaMultiValueSessionSerializer(
(JFunction1<SomeJavaComplexObject, Map<String, String>>) sjco -> {
final java.util.Map<String, String> m = new HashMap<>();
m.put("value", sjco.getValue());
return MapConverters.toImmutableMap(m);
},
(JFunction1<Map<String, String>, Try<SomeJavaComplexObject>>) value ->
Try.apply((JFunction0<SomeJavaComplexObject>) () -> new SomeJavaComplexObject(value.get("value").get()))
);
}
示例10: createMatch
import scala.collection.immutable.Map; //导入依赖的package包/类
public static IngraphMatch createMatch(final RailwayQuery query, final Map<Object, Object> qs) {
switch (query) {
case CONNECTEDSEGMENTS:
return new IngraphConnectedSegmentsMatch(qs);
case CONNECTEDSEGMENTS_INJECT:
return new IngraphConnectedSegmentsInjectMatch(qs);
case POSLENGTH:
return new IngraphPosLengthMatch(qs);
case POSLENGTH_INJECT:
return new IngraphPosLengthInjectMatch(qs);
case ROUTESENSOR:
return new IngraphRouteSensorMatch(qs);
case ROUTESENSOR_INJECT:
return new IngraphRouteSensorInjectMatch(qs);
case SEMAPHORENEIGHBOR:
return new IngraphSemaphoreNeighborMatch(qs);
case SEMAPHORENEIGHBOR_INJECT:
return new IngraphSemaphoreNeighborInjectMatch(qs);
case SWITCHMONITORED:
return new IngraphSwitchMonitoredMatch(qs);
case SWITCHMONITORED_INJECT:
return new IngraphSwitchMonitoredInjectMatch(qs);
case SWITCHSET:
return new IngraphSwitchSetMatch(qs);
case SWITCHSET_INJECT:
return new IngraphSwitchSetInjectMatch(qs);
default:
throw new UnsupportedOperationException("Pattern not supported: " + query);
}
}
示例11: activate
import scala.collection.immutable.Map; //导入依赖的package包/类
@Override
public void activate(final Collection<IngraphRouteSensorMatch> matches) throws IOException {
final Transaction transaction = driver.newTransaction();
for (final IngraphRouteSensorMatch match : matches) {
final Long route = match.getRoute();
final Long sensor = match.getSensor();
transaction.add("_e4", new Map.Map2("route", route, "sensor", sensor));
}
}
示例12: activate
import scala.collection.immutable.Map; //导入依赖的package包/类
@Override
public void activate(final Collection<IngraphSemaphoreNeighborMatch> matches) throws IOException {
final Transaction transaction = driver.newTransaction();
for (final IngraphSemaphoreNeighborMatch match : matches) {
final Long route2 = match.getRoute2();
final Long semaphore = match.getSemaphore();
transaction.add(ENTRY, new Map.Map2<>("route2", route2, "semaphore", semaphore));
}
}
示例13: getConfiguration
import scala.collection.immutable.Map; //导入依赖的package包/类
protected Configuration getConfiguration(
String defaultHost,
int defaultPort,
String defaultDatabase,
String defaultUser,
String defaultPassword,
String defaultCharset,
long defaultConnectTimeout,
long defaultTestTimeout,
JsonObject config) {
String host = config.getString("host", defaultHost);
int port = config.getInteger("port", defaultPort);
String username = config.getString("username", defaultUser);
String password = config.getString("password", defaultPassword);
String database = config.getString("database", defaultDatabase);
Charset charset = Charset.forName(config.getString("charset", defaultCharset));
long connectTimeout = config.getLong("connectTimeout", defaultConnectTimeout);
long testTimeout = config.getLong("testTimeout", defaultTestTimeout);
Long queryTimeout = config.getLong("queryTimeout");
Option<Duration> queryTimeoutOption = (queryTimeout == null) ?
Option.empty() : Option.apply(Duration.apply(queryTimeout, TimeUnit.MILLISECONDS));
Map<String, String> sslConfig = buildSslConfig(config);
log.info("Creating configuration for " + host + ":" + port);
return new Configuration(
username,
host,
port,
Option.apply(password),
Option.apply(database),
SSLConfiguration.apply(sslConfig),
charset,
16777216,
PooledByteBufAllocator.DEFAULT,
Duration.apply(connectTimeout, TimeUnit.MILLISECONDS),
Duration.apply(testTimeout, TimeUnit.MILLISECONDS),
queryTimeoutOption);
}
示例14: buildSslConfig
import scala.collection.immutable.Map; //导入依赖的package包/类
private Map<String, String> buildSslConfig(JsonObject config) {
Map<String, String> sslConfig = Map$.MODULE$.empty();
if (config.getString("sslMode")!= null) {
sslConfig = sslConfig.$plus(Tuple2.apply("sslmode", config.getString("sslMode")));
}
if (config.getString("sslRootCert") != null) {
sslConfig = sslConfig.$plus(Tuple2.apply("sslrootcert", config.getString("sslRootCert")));
}
return sslConfig;
}
示例15: read
import scala.collection.immutable.Map; //导入依赖的package包/类
@Override
public Option<Model> read(Class<?> cls, Map<String, String> typeMap) {
Option<Model> model = super.read(cls, typeMap);
for (Field field : cls.getDeclaredFields()) {
handleExcludedAnnotations(cls, field, model);
}
return model;
}