Package com.datastax.driver.core

Examples of com.datastax.driver.core.Session$State


    public void should_allow_dynamic_schema_update_for_cluster_counter() throws Exception {
        //Given
        Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
        UUID date = UUIDGen.getTimeUUID();

        final Session session = CassandraEmbeddedServerBuilder
                .withEntities(Arrays.<Class<?>>asList(CompleteBean.class))
                .withKeyspaceName("schema_dynamic_update_counter")
                .cleanDataFilesAtStartup(true)
                .buildNativeSessionOnly();
        session.execute("DROP TABLE IF EXISTS new_counter_field");
        session.execute("CREATE TABLE new_counter_field(id bigint, date timeuuid, existing_counter counter, PRIMARY KEY(id,date))");

        //When
        final PersistenceManagerFactory pmf = PersistenceManagerFactoryBuilder.builder(session.getCluster())
                .withEntities(Arrays.<Class<?>>asList(ClusteredCounterEntityWithNewCounterField.class))
                .enableSchemaUpdate(true)
                .build();

        final PersistenceManager pm = pmf.createPersistenceManager();
        pm.insert(new ClusteredCounterEntityWithNewCounterField(id, date, CounterBuilder.incr(12L)));

        //Then
        assertThat(pm.find(ClusteredCounterEntityWithNewCounterField.class, new ClusteredCounterEntityWithNewCounterField.Compound(id, date))).isNotNull();

        session.close();
    }
View Full Code Here


    }

    @Test(expected = AchillesInvalidTableException.class)
    public void should_fail_bootstrapping_if_schema_update_forbidden_for_entity() throws Exception {
        //Given
        final Session session = CassandraEmbeddedServerBuilder
                .noEntityPackages().withKeyspaceName("schema_dynamic_update_fail")
                .cleanDataFilesAtStartup(true)
                .buildNativeSessionOnly();
        session.execute("DROP TABLE IF EXISTS new_simple_field");
        session.execute("CREATE TABLE new_simple_field(id bigint PRIMARY KEY, existing_field text)");

        //When
        PersistenceManagerFactoryBuilder.builder(session.getCluster())
                .withEntities(Arrays.<Class<?>>asList(EntityWithNewSimpleField.class))
                .withKeyspaceName("schema_dynamic_update_fail")
                .enableSchemaUpdate(true)
                .enableSchemaUpdateForTables(ImmutableMap.of("schema_dynamic_update_fail.new_simple_field", false))
                .build();

        session.close();
    }
View Full Code Here

    }

    @Test(expected = AchillesInvalidTableException.class)
    public void should_fail_bootstrapping_if_index_validation_fails() throws Exception {
        //Given
        final Session session = CassandraEmbeddedServerBuilder
                .noEntityPackages().withKeyspaceName("schema_dynamic_update")
                .cleanDataFilesAtStartup(true)
                .buildNativeSessionOnly();

        //When
        PersistenceManagerFactoryBuilder.builder(session.getCluster())
                .withEntities(Arrays.<Class<?>>asList(EntityWithNewSimpleField.class))
                .enableSchemaUpdate(true)
                .enableSchemaUpdateForTables(ImmutableMap.of("schema_dynamic_update.new_simple_field", false))
                .relaxIndexValidation(false)
                .build();

        session.close();
    }
View Full Code Here

    public void should_use_custom_bean_validator_interceptor() throws Exception {
        // Given
        Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
        boolean exceptionRaised = false;

        Session nativeSession = this.manager.getNativeSession();
        Cluster cluster = nativeSession.getCluster();
        CustomValidationInterceptor interceptor = new CustomValidationInterceptor();

        Map<ConfigurationParameters, Object> configMap = new HashMap<>();
        configMap.put(NATIVE_SESSION, nativeSession);
        configMap.put(ENTITIES_LIST, Arrays.asList(EntityWithGroupConstraint.class));
View Full Code Here

    private Session session = CassandraEmbeddedServerBuilder.noEntityPackages().withKeyspaceName("test_keyspace")
            .buildNativeSessionOnly();

    @Test
    public void should_return_same_native_session() throws Exception {
        Session session = CassandraEmbeddedServerBuilder.noEntityPackages().withKeyspaceName("test_keyspace")
                .buildNativeSessionOnly();

        assertThat(session).isSameAs(this.session);
    }
View Full Code Here

      throw new RuntimeException(
          "Cassandra cluster has not yet been initialized!");
    }
    try {
      _log.info("Started connecting to cluster...");
      final Session session = _cluster.connect(_configuration
          .getKeyspace());
      _log.info("Finished connecting to cluster...");
      return new CassandraVirtualDataWindow(session, context);
    } catch (Exception e) {
      _log.error("Error connecting to cluster!");
View Full Code Here

    @Override
    public CompletionContext<State> buildContext(
        SelectionModel selection, DocumentParser parser) {
      JsonArray<Token> tokens = JsonCollections.createArray();
      State state = TestUtils.createMockState();
      tokens.add(new Token(null, NULL, ""));
      ParseResult<State> parseResult = new ParseResult<State>(tokens, state) {};
      return buildContext(
          new ParseUtils.ExtendedParseResult<State>(parseResult, ParseUtils.Context.IN_CODE));
    }
View Full Code Here

   * @param anchorToUpdate the optional anchor that this method will update
   */
  private boolean parseImplCm2(Line line, int lineNumber, int numLinesToProcess,
      @Nullable Anchor anchorToUpdate, ParsedTokensRecipient tokensRecipient) {

    State parserState = loadParserStateForBeginningOfLine(line);
    if (parserState == null) {
      return false;
    }

    Line previousLine = line.getPreviousLine();

    for (int numLinesProcessed = 0; line != null && numLinesProcessed < numLinesToProcess;) {
      State stateToSave = parserState;
      if (line.getText().length() > LINE_LENGTH_LIMIT) {
        // Save the initial state instead of state at the end of line.
        stateToSave = parserState.copy(codeMirrorParser);
      }

View Full Code Here

    parseImplCm2(line, -1, 1, null, tokensRecipient);
    return tokensRecipient.tokens;
  }

  int getIndentation(Line line) {
    State stateBefore = loadParserStateForBeginningOfLine(line);
    String textAfter = line.getText();
    textAfter = textAfter.substring(StringUtils.lengthOfStartingWhitespace(textAfter));
    return codeMirrorParser.indent(stateBefore, textAfter);
  }
View Full Code Here

   *
   * @return copy of corresponding parser state, or {@code null} if the state
   *         if not known yet (previous line wasn't parsed).
   */
  private <T extends State> T loadParserStateForBeginningOfLine(TaggableLine line) {
    State state;
    if (line.isFirstLine()) {
      state = codeMirrorParser.defaultState();
    } else {
      state = line.getPreviousLine().getTag(LINE_TAG_END_OF_LINE_PARSER_STATE_SNAPSHOT);
      state = (state == null) ? null : state.copy(codeMirrorParser);
    }

    @SuppressWarnings("unchecked")
    T result = (T) state;
    return result;
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.Session$State

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.