Package info.archinnov.achilles.type

Examples of info.archinnov.achilles.type.TypedMap


     * Build CQL Persistence Manager Factory
     *
     * @return PersistenceManagerFactory
     */
    public PersistenceManagerFactory buildPersistenceManagerFactory() {
        TypedMap parameters = buildConfigMap();
        ConfigMap achillesParameters = buildAchillesConfigMap();
        String keyspace = achillesParameters.getTyped(KEYSPACE_NAME);
        final CassandraEmbeddedServer embeddedServer = new CassandraEmbeddedServer(parameters, achillesParameters);
        return embeddedServer.getPersistenceManagerFactory(keyspace);
    }
View Full Code Here


     * Build CQL Persistence Manager
     *
     * @return PersistenceManager
     */
    public PersistenceManager buildPersistenceManager() {
        TypedMap parameters = buildConfigMap();
        ConfigMap achillesParameters = buildAchillesConfigMap();
        String keyspace = achillesParameters.getTyped(KEYSPACE_NAME);
        final CassandraEmbeddedServer embeddedServer = new CassandraEmbeddedServer(parameters, achillesParameters);
        return embeddedServer.getPersistenceManager(keyspace);
    }
View Full Code Here

     *
     * @return native Java driver core Session
     */
    public Session buildNativeSessionOnly() {
        this.buildNativeSessionOnly = true;
        TypedMap parameters = buildConfigMap();
        ConfigMap achillesParameters = buildAchillesConfigMap();
        String keyspace = achillesParameters.getTyped(KEYSPACE_NAME);
        final CassandraEmbeddedServer embeddedServer = new CassandraEmbeddedServer(parameters, achillesParameters);
        return embeddedServer.getNativeSession(keyspace);
    }
View Full Code Here

        config.putAll(achillesConfigParams);
        return config;
    }

    private TypedMap buildConfigMap() {
        TypedMap config = new TypedMap();
        config.put(CLEAN_CASSANDRA_DATA_FILES, cleanDataFiles);
        config.put(CLEAN_CASSANDRA_CONFIG_FILE, cleanConfigFile);

        if (StringUtils.isNotBlank(dataFileFolder))
            config.put(DATA_FILE_FOLDER, dataFileFolder);

        if (StringUtils.isNotBlank(commitLogFolder))
            config.put(COMMIT_LOG_FOLDER, commitLogFolder);

        if (StringUtils.isNotBlank(savedCachesFolder))
            config.put(SAVED_CACHES_FOLDER, savedCachesFolder);

        if (StringUtils.isNotBlank(configYamlFile))
            config.put(CONFIG_YAML_FILE, configYamlFile);

        if (StringUtils.isNotBlank(clusterName))
            config.put(CLUSTER_NAME, clusterName);

        if (cqlPort > 0)
            config.put(CASSANDRA_CQL_PORT, cqlPort);

        if (thriftPort > 0)
            config.put(CASSANDRA_THRIFT_PORT, thriftPort);

        if (storagePort > 0)
            config.put(CASSANDRA_STORAGE_PORT, storagePort);

        if (storageSSLPort > 0)
            config.put(CASSANDRA_STORAGE_SSL_PORT, storageSSLPort);

        config.put(KEYSPACE_DURABLE_WRITE, durableWrite);
        config.put(BUILD_NATIVE_SESSION_ONLY, buildNativeSessionOnly);

        TypedMap parameters = CassandraEmbeddedConfigParameters.mergeWithDefaultParameters(config);
        return parameters;
    }
View Full Code Here

     * @param originalParameters embedded Cassandra server parameters
     * @param achillesParameters Achilles parameters
     */
    public CassandraEmbeddedServer(TypedMap originalParameters, ConfigMap achillesParameters) {
        LOGGER.trace("Start Cassandra Embedded server with server and Achilles config");
        TypedMap parameters = CassandraEmbeddedConfigParameters.mergeWithDefaultParameters(originalParameters);
        String cassandraHost = System.getProperty(CASSANDRA_HOST);

        // No external Cassandra server, start an embedded instance
        if (StringUtils.isBlank(cassandraHost)) {
            synchronized (SEMAPHORE) {
View Full Code Here

        super(cleanUpSteps, tables);
        initResource(configMap);
    }

    private void initResource(ConfigMap achillesConfig) {
        TypedMap cassandraConfig = buildConfigMap();
        buildAchillesConfigMap(achillesConfig);

        server = new CassandraEmbeddedServer(cassandraConfig, achillesConfig);
        pmf = server.getPersistenceManagerFactory(keyspaceToUse);
        manager = server.getPersistenceManager(keyspaceToUse);
View Full Code Here

        manager = server.getPersistenceManager(keyspaceToUse);
        session = server.getNativeSession(keyspaceToUse);
    }

    private TypedMap buildConfigMap() {
        TypedMap config = new TypedMap();
        config.put(CLEAN_CASSANDRA_DATA_FILES, true);
        config.put(KEYSPACE_DURABLE_WRITE, false);
        return config;
    }
View Full Code Here

    /**
     * Default values
     */

    static TypedMap mergeWithDefaultParameters(TypedMap parameters) {
        TypedMap defaultParams = new TypedMap();
        defaultParams.put(CLEAN_CASSANDRA_DATA_FILES, true);
        defaultParams.put(CLEAN_CASSANDRA_CONFIG_FILE, true);
        defaultParams.put(DATA_FILE_FOLDER, DEFAULT_ACHILLES_TEST_DATA_FOLDER);
        defaultParams.put(COMMIT_LOG_FOLDER, DEFAULT_ACHILLES_TEST_COMMIT_LOG_FOLDER);
        defaultParams.put(SAVED_CACHES_FOLDER, DEFAULT_ACHILLES_TEST_SAVED_CACHES_FOLDER);
        defaultParams.put(CONFIG_YAML_FILE, DEFAULT_ACHILLES_TEST_CONFIG_YAML_FILE);
        defaultParams.put(CLUSTER_NAME, DEFAULT_CASSANDRA_EMBEDDED_CLUSTER_NAME);
        defaultParams.put(KEYSPACE_NAME, DEFAULT_CASSANDRA_EMBEDDED_KEYSPACE_NAME);
        defaultParams.put(KEYSPACE_DURABLE_WRITE, DEFAULT_CASSANDRA_EMBEDDED_KEYSPACE_DURABLE_WRITE);
        defaultParams.put(COMPRESSION_TYPE, Compression.NONE);
        defaultParams.put(LOAD_BALANCING_POLICY, Policies.defaultLoadBalancingPolicy());
        defaultParams.put(RETRY_POLICY, Policies.defaultRetryPolicy());
        defaultParams.put(RECONNECTION_POLICY, Policies.defaultReconnectionPolicy());
        defaultParams.put(BUILD_NATIVE_SESSION_ONLY, false);
        defaultParams.putAll(parameters);

        return defaultParams;
    }
View Full Code Here

    public TypedMap mapRow(Row row) {
    log.trace("Map CQL row to a map of <ColumnName,Value>");
    ColumnDefinitions columnDefinitions = row.getColumnDefinitions();
        Validator.validateNotNull(columnDefinitions,"Impossible to fetch column definitions for the row '%s'", row);
        TypedMap line = new TypedMap();
        for (Definition column : columnDefinitions) {
            line.put(column.getName(), mapColumn(row, column));
        }
        return line;
    }
View Full Code Here

    @Test
    public void should_get_first_async() throws Exception {
        // Given
        List<Row> rows = Arrays.asList(row);
        TypedMap typedMap = new TypedMap();
        List<TypedMap> typedMaps = new ArrayList<>();
        typedMaps.add(typedMap);

        when(daoContext.execute(any(NativeStatementWrapper.class))).thenReturn(futureResultSet);
        when(asyncUtils.transformFuture(futureResultSet, RESULTSET_TO_ROWS, executorService)).thenReturn(futureRows);
        when(asyncUtils.transformFuture(eq(futureRows), rowsToTypedMapCaptor.capture(), eq(executorService))).thenReturn(futureTypedMap);
        when(asyncUtils.buildInterruptible(futureTypedMap)).thenReturn(achillesFutureTypedMap);

        when(mapper.mapRows(rows)).thenReturn(typedMaps);

        // When
        final AchillesFuture<TypedMap> actual = query.asyncFirst(asyncListeners);

        // Then
        assertThat(actual).isSameAs(achillesFutureTypedMap);
        verify(asyncUtils).maybeAddAsyncListeners(futureTypedMap, asyncListeners, executorService);

        final Function<List<Row>, TypedMap> function = rowsToTypedMapCaptor.getValue();
        final TypedMap actualTypedMap = function.apply(rows);
        assertThat(actualTypedMap).isSameAs(typedMap);

    }
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.type.TypedMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.