当前位置: 首页>>代码示例>>Java>>正文


Java MappingManager类代码示例

本文整理汇总了Java中com.datastax.driver.mapping.MappingManager的典型用法代码示例。如果您正苦于以下问题:Java MappingManager类的具体用法?Java MappingManager怎么用?Java MappingManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MappingManager类属于com.datastax.driver.mapping包,在下文中一共展示了MappingManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startComponent

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
@Override
public void startComponent() {
  if (cluster == null) {
    // Configure and build up the Cassandra cluster.
    cluster = Cluster.builder()
            .withClusterName(clusterName)
            .withPort(port)
            .withRetryPolicy(DefaultRetryPolicy.INSTANCE)
            // TokenAware requires query has routing info (e.g. BoundStatement with all PK value bound).
            .withLoadBalancingPolicy(new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().build()))
            .addContactPoints(contactPoints.toArray(new String[contactPoints.size()]))
            .build();

    // Register any codecs.
    cluster.getConfiguration().getCodecRegistry()
            .register(new CassandraEnumCodec<>(AccessMode.class, AccessMode.getValueMap()))
            .register(new CassandraEnumCodec<>(Direction.class, Direction.getValueMap()))
            .register(new CassandraEnumCodec<>(SourceEntity.Type.class, SourceEntity.Type.getValueMap()));

    // Create a session.
    manager = new MappingManager(cluster.connect());
  }
}
 
开发者ID:mnemonic-no,项目名称:act-platform,代码行数:24,代码来源:ClusterManager.java

示例2: initSession

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
private void initSession() {
    long endTime = System.currentTimeMillis() + initTimeout;
    while (System.currentTimeMillis() < endTime) {
        try {

            if (this.keyspaceName != null) {
                session = cluster.connect(keyspaceName);
            } else {
                session = cluster.connect();
            }
            mappingManager = new MappingManager(session);
            break;
        } catch (Exception e) {
            log.warn("Failed to initialize cassandra cluster due to {}. Will retry in {} ms", e.getMessage(), initRetryInterval);
            try {
                Thread.sleep(initRetryInterval);
            } catch (InterruptedException ie) {
                log.warn("Failed to wait until retry", ie);
            }
        }
    }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:23,代码来源:AbstractCassandraCluster.java

示例3: MyInterceptor

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
MyInterceptor(Class<?> entityCls, boolean singleton) {
	super();
	this.entityCls = entityCls;
	this.targetInitializer = () -> {
		if (singleton)
			log.info("Creating actual mapper for entity: " + entityCls.getName());
		Session session;
		if (MapperScannerConfigurer.this.session == null)
			session = mainContext.getBean(Session.class);
		else
			session = MapperScannerConfigurer.this.session;
		MappingManager mappingManager = new MappingManager(session);
		return mappingManager.mapper(entityCls);
	};
	this.singleton = singleton;
	if (singleton)
		this.singletonTarget = new Lazy<>(targetInitializer);
	else
		this.singletonTarget = null;
}
 
开发者ID:NewTranx,项目名称:newtranx-utils,代码行数:21,代码来源:MapperScannerConfigurer.java

示例4: init

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
public void init(Class<T> tClass) {
    try {
        Cluster.Builder builder = Cluster.builder();
        final String[] nodesList = nodes.split(",");
        for (String node : nodesList) {
            builder.addContactPoint(node).withPort(Integer.parseInt(port));
            LOGGER.info(String.format("Added cassandra node : %s", node + ":" + port));
        }
        cluster = builder.build();
        session = null;
        if (keyspace != null) {
            session = cluster.connect(keyspace);
        } else {
            session = cluster.connect();
        }
        MappingManager mappingManager = new MappingManager(session);
        mapper = mappingManager.mapper(tClass);
    } catch (Exception e) {
        LOGGER.error("Error initializing CassandraDao");
        throw e;
    }
}
 
开发者ID:echauchot,项目名称:bigDataRocks,代码行数:23,代码来源:ACassandraDao.java

示例5: initializeUDTs

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
private static void initializeUDTs(Session session) {
  Schema.ensureExists(DEFAULT_KEYSPACE + "_udts", session);
  MappingManager mapping = new MappingManager(session);

  // The UDTs are hardcoded against the zipkin keyspace.
  // If a different keyspace is being used the codecs must be re-applied to this different keyspace
  TypeCodec<TraceIdUDT> traceIdCodec = mapping.udtCodec(TraceIdUDT.class);
  TypeCodec<EndpointUDT> endpointCodec = mapping.udtCodec(EndpointUDT.class);
  TypeCodec<AnnotationUDT> annoCodec = mapping.udtCodec(AnnotationUDT.class);
  TypeCodec<BinaryAnnotationUDT> bAnnoCodec = mapping.udtCodec(BinaryAnnotationUDT.class);

  KeyspaceMetadata keyspace =
      session.getCluster().getMetadata().getKeyspace(session.getLoggedKeyspace());

  session.getCluster().getConfiguration().getCodecRegistry()
      .register(
          new TypeCodecImpl(keyspace.getUserType("trace_id"), TraceIdUDT.class, traceIdCodec))
      .register(
          new TypeCodecImpl(keyspace.getUserType("endpoint"), EndpointUDT.class, endpointCodec))
      .register(
          new TypeCodecImpl(keyspace.getUserType("annotation"), AnnotationUDT.class, annoCodec))
      .register(
          new TypeCodecImpl(keyspace.getUserType("binary_annotation"), BinaryAnnotationUDT.class,
              bAnnoCodec));
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:26,代码来源:DefaultSessionFactory.java

示例6: init

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
@PostConstruct
public void init() {
    mapper = new MappingManager(session).mapper(PersistentToken.class);

    findPersistentTokenSeriesByUserIdStmt = session.prepare(
        "SELECT persistent_token_series " +
        "FROM persistent_token_by_user " +
        "WHERE user_id = :user_id");

    insertPersistentTokenSeriesByUserIdStmt = session.prepare(
        "INSERT INTO persistent_token_by_user (user_id, persistent_token_series) " +
            "VALUES (:user_id, :persistent_token_series) " +
            "USING TTL 2592000"); // 30 days

    insertPersistentTokenStmt = session.prepare(
        "INSERT INTO persistent_token (series, token_date, user_agent, token_value, login, user_id, ip_address) " +
            "VALUES (:series, :token_date, :user_agent, :token_value, :login, :user_id, :ip_address) " +
            "USING TTL 2592000"); // 30 days
}
 
开发者ID:xetys,项目名称:jhipster-ribbon-hystrix,代码行数:20,代码来源:_PersistentTokenRepository.java

示例7: CassandraExecutor

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
public CassandraExecutor(final Session session, final StatementSettings settings, final CQLMapper cqlMapper, final NamingPolicy namingPolicy,
        final AsyncExecutor asyncExecutor) {
    this.cluster = session.getCluster();
    this.session = session;
    this.codecRegistry = cluster.getConfiguration().getCodecRegistry();
    this.mappingManager = new MappingManager(session);

    if (settings == null) {
        this.settings = null;
    } else {
        this.settings = settings.copy();
    }

    this.cqlMapper = cqlMapper;
    this.namingPolicy = namingPolicy == null ? NamingPolicy.LOWER_CASE_WITH_UNDERSCORE : namingPolicy;
    this.asyncExecutor = asyncExecutor == null ? new AsyncExecutor(64, 300, TimeUnit.SECONDS) : asyncExecutor;
}
 
开发者ID:landawn,项目名称:AbacusUtil,代码行数:18,代码来源:CassandraExecutor.java

示例8: initSession

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
private void initSession() {
    long endTime = System.currentTimeMillis() + initTimeout;
    while (System.currentTimeMillis() < endTime) {
        try {
            cluster = clusterBuilder.build();
            cluster.init();
            if (this.keyspaceName != null) {
                session = cluster.connect(keyspaceName);
            } else {
                session = cluster.connect();
            }
            mappingManager = new MappingManager(session);
            break;
        } catch (Exception e) {
            log.warn("Failed to initialize cassandra cluster due to {}. Will retry in {} ms", e.getMessage(), initRetryInterval);
            try {
                Thread.sleep(initRetryInterval);
            } catch (InterruptedException ie) {
                log.warn("Failed to wait until retry", ie);
                Thread.currentThread().interrupt();
            }
        }
    }
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:25,代码来源:AbstractCassandraCluster.java

示例9: connect

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
@PostConstruct
public void connect() {
    cluster = Cluster.builder()
            .addContactPoint(getContactPoints())
            .withPort(getPort())
            .withPoolingOptions(new PoolingOptions())
            .build();
    Metadata metadata = cluster.getMetadata();
    log.info("Connected to cluster: "+ metadata.getClusterName());
    for (Host host : metadata.getAllHosts()) {
        log.info("Datacenter: "+host.getDatacenter()+" Host: "+host.getAddress()+ " Rack: " + host.getRack());
    }

    session = cluster.connect(getKeyspace());

    manager = new MappingManager(session);
}
 
开发者ID:Eventasia,项目名称:eventasia,代码行数:18,代码来源:EventasiaCassandraConfig.java

示例10: open

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
@Override
public void open(Configuration configuration) {
	super.open(configuration);
	try {
		this.mappingManager = new MappingManager(session);
		this.mapper = mappingManager.mapper(clazz);
		if (options != null) {
			Mapper.Option[] optionsArray = options.getMapperOptions();
			if (optionsArray != null) {
				this.mapper.setDefaultSaveOptions(optionsArray);
			}
		}
	} catch (Exception e) {
		throw new RuntimeException("Cannot create CassandraPojoSink with input: " + clazz.getSimpleName(), e);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:CassandraPojoSink.java

示例11: connect

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
@Override
public Connection connect() throws CEUException {
	DSConnection dsConnection = null;

	if (keyspaceDefault != null) {
		dsConnection = new DSConnection(this,
				coreCluster.connect(keyspaceDefault));

		// não precisa guardar pra manipular posteriormente ?
		new MappingManager(dsConnection.getCoreSession());

	} else {
		dsConnection = new DSConnection(this, coreCluster.connect());
	}
	return dsConnection;
}
 
开发者ID:Taulukko,项目名称:taulukko-commons-ceu,代码行数:17,代码来源:DSCluster.java

示例12: NativeSerializer

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
NativeSerializer(CassandraClient cassandraClient, Class<K> keyClass, Class<T> persistentClass, CassandraMapping mapping) {
  super(cassandraClient, keyClass, persistentClass, mapping);
  try {
    analyzePersistent();
  } catch (Exception e) {
    throw new RuntimeException("Error occurred while analyzing the persistent class, :" + e.getMessage());
  }
  this.createSchema();
  MappingManager mappingManager = new MappingManager(cassandraClient.getSession());
  mapper = mappingManager.mapper(persistentClass);
  if (cassandraClient.getWriteConsistencyLevel() != null) {
    mapper.setDefaultDeleteOptions(Mapper.Option.consistencyLevel(ConsistencyLevel.valueOf(cassandraClient.getWriteConsistencyLevel())));
    mapper.setDefaultSaveOptions(Mapper.Option.consistencyLevel(ConsistencyLevel.valueOf(cassandraClient.getWriteConsistencyLevel())));
  }
  if (cassandraClient.getReadConsistencyLevel() != null) {
    mapper.setDefaultGetOptions(Mapper.Option.consistencyLevel(ConsistencyLevel.valueOf(cassandraClient.getReadConsistencyLevel())));
  }
}
 
开发者ID:apache,项目名称:gora,代码行数:19,代码来源:NativeSerializer.java

示例13: connectViaConnectionString

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
@Test
public void connectViaConnectionString() throws Exception {
  new MockUnit(Env.class, Config.class, Binder.class, Cluster.class, Cluster.Builder.class,
      Configuration.class, Session.class)
      .expect(clusterBuilder)
      .expect(serviceKey(new Env.ServiceKey()))
      .expect(contactPoints("localhost"))
      .expect(port(9042))
      .expect(codecRegistry)
      .expect(bind("beers", Cluster.class))
      .expect(bind(null, Cluster.class))
      .expect(bind("beers", Session.class))
      .expect(bind(null, Session.class))
      .expect(connect("beers"))
      .expect(mapper)
      .expect(bind("beers", MappingManager.class))
      .expect(bind(null, MappingManager.class))
      .expect(datastore)
      .expect(bind("beers", Datastore.class))
      .expect(bind(null, Datastore.class))
      .expect(routeMapper).expect(onStop)
      .run(unit -> {
        new Cassandra("cassandra://localhost/beers")
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:27,代码来源:CassandraTest.java

示例14: connectViaConnectionStringSupplier

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
@Test
public void connectViaConnectionStringSupplier() throws Exception {
  new MockUnit(Env.class, Config.class, Binder.class, Cluster.class, Cluster.Builder.class,
      Configuration.class, Session.class)
      .expect(clusterBuilderProvider)
      .expect(serviceKey(new Env.ServiceKey()))
      .expect(contactPoints("localhost"))
      .expect(port(9042))
      .expect(codecRegistry)
      .expect(bind("beers", Cluster.class))
      .expect(bind(null, Cluster.class))
      .expect(bind("beers", Session.class))
      .expect(bind(null, Session.class))
      .expect(connect("beers"))
      .expect(mapper)
      .expect(bind("beers", MappingManager.class))
      .expect(bind(null, MappingManager.class))
      .expect(datastore)
      .expect(bind("beers", Datastore.class))
      .expect(bind(null, Datastore.class))
      .expect(routeMapper).expect(onStop)
      .run(unit -> {
        new Cassandra("cassandra://localhost/beers", () -> unit.get(Cluster.Builder.class))
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:27,代码来源:CassandraTest.java

示例15: PersistentTokenRepository

import com.datastax.driver.mapping.MappingManager; //导入依赖的package包/类
public PersistentTokenRepository(Session session, Validator validator) {
    this.session = session;
    this.validator = validator;
    mapper = new MappingManager(session).mapper(PersistentToken.class);

    findPersistentTokenSeriesByUserIdStmt = session.prepare(
        "SELECT persistent_token_series " +
        "FROM persistent_token_by_user " +
        "WHERE user_id = :user_id");

    insertPersistentTokenSeriesByUserIdStmt = session.prepare(
        "INSERT INTO persistent_token_by_user (user_id, persistent_token_series) " +
            "VALUES (:user_id, :persistent_token_series) " +
            "USING TTL 2592000"); // 30 days

    insertPersistentTokenStmt = session.prepare(
        "INSERT INTO persistent_token (series, token_date, user_agent, token_value, login, user_id, ip_address) " +
            "VALUES (:series, :token_date, :user_agent, :token_value, :login, :user_id, :ip_address) " +
            "USING TTL 2592000"); // 30 days

    deletePersistentTokenSeriesByUserIdStmt = session.prepare(
        "DELETE FROM persistent_token_by_user WHERE user_id = :user_id AND persistent_token_series = :persistent_token_series"
    );
}
 
开发者ID:jhipster,项目名称:generator-jhipster,代码行数:25,代码来源:_PersistentTokenRepository.java


注:本文中的com.datastax.driver.mapping.MappingManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。