com.hazelcast.test.TestHazelcastInstanceFactory Java Examples

The following examples show how to use com.hazelcast.test.TestHazelcastInstanceFactory. 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: SnowcastSequenceUtilsTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test
public void test_comparator_first_lower_by_counter()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        int boundedNodeCount = calculateBoundedMaxLogicalNodeCount(SnowcastConstants.DEFAULT_MAX_LOGICAL_NODES_13_BITS);
        int shifting = calculateLogicalNodeShifting(boundedNodeCount);
        long sequence1 = generateSequenceId(10000, 1, 1, shifting);
        long sequence2 = generateSequenceId(10000, 1, 2, shifting);

        Comparator<Long> comparator = SnowcastSequenceUtils.snowcastSequenceComparator(sequencer);

        assertEquals(-1, comparator.compare(sequence1, sequence2));
    } finally {
        factory.shutdownAll();
    }
}
 
Example #2
Source File: DistributedCacheTest.java    From foxtrot with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    mapper = new ObjectMapper();
    mapper = spy(mapper);
    hazelcastInstance = new TestHazelcastInstanceFactory(1).newHazelcastInstance();
    HazelcastConnection hazelcastConnection = Mockito.mock(HazelcastConnection.class);
    when(hazelcastConnection.getHazelcast()).thenReturn(hazelcastInstance);
    when(hazelcastConnection.getHazelcastConfig()).thenReturn(new Config());
    distributedCache = new DistributedCache(hazelcastConnection, "TEST", mapper);
    CacheManager cacheManager = new CacheManager(new DistributedCacheFactory(hazelcastConnection, mapper, new CacheConfig()));

    TableMetadataManager tableMetadataManager = Mockito.mock(TableMetadataManager.class);
    when(tableMetadataManager.exists(TestUtils.TEST_TABLE_NAME)).thenReturn(true);
    QueryStore queryStore = Mockito.mock(QueryStore.class);

    AnalyticsLoader analyticsLoader = new AnalyticsLoader(tableMetadataManager, null, queryStore,
            null, cacheManager, mapper, new ElasticsearchTuningConfig());
    TestUtils.registerActions(analyticsLoader, mapper);
}
 
Example #3
Source File: MultiNodeTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test(expected = SnowcastStateException.class)
public void test_id_generation_in_detached_state()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(2);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();
    factory.newHazelcastInstance();

    try {
        String sequencerName = generateKeyNotOwnedBy(hazelcastInstance);
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast, sequencerName);

        assertNotNull(sequencer);
        assertNotNull(sequencer.next());

        // Detach the node and free the currently used logical node ID
        sequencer.detachLogicalNode();

        sequencer.next();
    } finally {
        factory.shutdownAll();
    }
}
 
Example #4
Source File: MultiNodeTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test
public void test_single_id_generation()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(2);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();
    factory.newHazelcastInstance();

    try {
        String sequencerName = generateKeyNotOwnedBy(hazelcastInstance);
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast, sequencerName);

        assertNotNull(sequencer);
        assertNotNull(sequencer.next());
    } finally {
        factory.shutdownAll();
    }
}
 
Example #5
Source File: MultiNodeTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test
public void test_simple_sequencer_initialization()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(2);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();
    factory.newHazelcastInstance();

    try {
        String sequencerName = generateKeyNotOwnedBy(hazelcastInstance);
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast, sequencerName);

        assertNotNull(sequencer);

        // Request the current state of the sequencer
        SnowcastSequenceState state = sequencer.getSequencerState();

        // Destroy the sequencer, cluster-wide operation
        snowcast.destroySequencer(sequencer);
    } finally {
        factory.shutdownAll();
    }
}
 
Example #6
Source File: SnowcastSequenceUtilsTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test
public void test_comparator_equal()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        int boundedNodeCount = calculateBoundedMaxLogicalNodeCount(SnowcastConstants.DEFAULT_MAX_LOGICAL_NODES_13_BITS);
        int shifting = calculateLogicalNodeShifting(boundedNodeCount);
        long sequence1 = generateSequenceId(10000, 1, 1, shifting);
        long sequence2 = generateSequenceId(10000, 2, 1, shifting);

        Comparator<Long> comparator = SnowcastSequenceUtils.snowcastSequenceComparator(sequencer);

        assertEquals(0, comparator.compare(sequence1, sequence2));
    } finally {
        factory.shutdownAll();
    }
}
 
Example #7
Source File: SnowcastSequenceUtilsTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test
public void test_comparator_first_lower_by_timestamp()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        int boundedNodeCount = calculateBoundedMaxLogicalNodeCount(SnowcastConstants.DEFAULT_MAX_LOGICAL_NODES_13_BITS);
        int shifting = calculateLogicalNodeShifting(boundedNodeCount);
        long sequence1 = generateSequenceId(10000, 1, 1, shifting);
        long sequence2 = generateSequenceId(10001, 1, 1, shifting);

        Comparator<Long> comparator = SnowcastSequenceUtils.snowcastSequenceComparator(sequencer);

        assertEquals(-1, comparator.compare(sequence1, sequence2));
    } finally {
        factory.shutdownAll();
    }
}
 
Example #8
Source File: SnowcastSequenceUtilsTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test
public void test_comparator_first_higher_by_timestamp()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        int boundedNodeCount = calculateBoundedMaxLogicalNodeCount(SnowcastConstants.DEFAULT_MAX_LOGICAL_NODES_13_BITS);
        int shifting = calculateLogicalNodeShifting(boundedNodeCount);
        long sequence1 = generateSequenceId(10000, 1, 1, shifting);
        long sequence2 = generateSequenceId(9999, 1, 1, shifting);

        Comparator<Long> comparator = SnowcastSequenceUtils.snowcastSequenceComparator(sequencer);

        assertEquals(1, comparator.compare(sequence1, sequence2));
    } finally {
        factory.shutdownAll();
    }
}
 
Example #9
Source File: BasicTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test
public void test_sequencer_logical_node_id()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        int boundedNodeCount = calculateBoundedMaxLogicalNodeCount(128);
        int shifting = calculateLogicalNodeShifting(boundedNodeCount);
        long sequence = generateSequenceId(10000, 10, 100, shifting);

        assertEquals(10, sequencer.logicalNodeId(sequence));
    } finally {
        factory.shutdownAll();
    }
}
 
Example #10
Source File: BasicTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test
public void test_sequencer_timestamp()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        int boundedNodeCount = calculateBoundedMaxLogicalNodeCount(128);
        int shifting = calculateLogicalNodeShifting(boundedNodeCount);
        long sequence = generateSequenceId(10000, 10, 100, shifting);

        assertEquals(10000, sequencer.timestampValue(sequence));
    } finally {
        factory.shutdownAll();
    }
}
 
Example #11
Source File: BasicTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test(expected = SnowcastSequencerAlreadyRegisteredException.class)
public void test_creation_wrong_definition()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        assertNotNull(sequencer);

        SnowcastEpoch epoch = SnowcastEpoch.byTimestamp(System.currentTimeMillis());
        buildSnowcastSequencer(snowcast, epoch);
    } finally {
        factory.shutdownAll();
    }
}
 
Example #12
Source File: BasicTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test
public void test_simple_sequencer_initialization()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        assertNotNull(sequencer);
    } finally {
        factory.shutdownAll();
    }
}
 
Example #13
Source File: BasicTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test
public void test_simple_sequencer_initialization_from_calendar()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencerFromCalendar(snowcast);

        assertNotNull(sequencer);
    } finally {
        factory.shutdownAll();
    }
}
 
Example #14
Source File: BasicTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test
public void test_simple_sequencer_initialization_declarative()
        throws Exception {

    ClassLoader classLoader = BasicTestCase.class.getClassLoader();
    InputStream stream = classLoader.getResourceAsStream("hazelcast-node-configuration.xml");
    Config config = new XmlConfigBuilder(stream).build();

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance(config);

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        assertNotNull(sequencer);
    } finally {
        factory.shutdownAll();
    }
}
 
Example #15
Source File: BasicTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test(expected = SnowcastStateException.class)
public void test_destroyed_state()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        assertNotNull(sequencer);
        assertNotNull(sequencer.next());

        snowcast.destroySequencer(sequencer);
        sequencer.next();

    } finally {
        factory.shutdownAll();
    }
}
 
Example #16
Source File: BasicTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test
public void test_sequencer_counter_value()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        int boundedNodeCount = calculateBoundedMaxLogicalNodeCount(128);
        int shifting = calculateLogicalNodeShifting(boundedNodeCount);
        long sequence = generateSequenceId(10000, 10, 100, shifting);

        assertEquals(100, sequencer.counterValue(sequence));
    } finally {
        factory.shutdownAll();
    }
}
 
Example #17
Source File: BasicTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test(expected = SnowcastStateException.class)
public void test_id_generation_in_detached_state()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        assertNotNull(sequencer);
        assertNotNull(sequencer.next());

        // Detach the node and free the currently used logical node ID
        sequencer.detachLogicalNode();

        sequencer.next();
    } finally {
        factory.shutdownAll();
    }
}
 
Example #18
Source File: BasicTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test(expected = SnowcastStateException.class)
public void test_id_generation_in_attach_wrong_state()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        assertNotNull(sequencer);

        sequencer.attachLogicalNode();
    } finally {
        factory.shutdownAll();
    }
}
 
Example #19
Source File: BasicTestCase.java    From snowcast with Apache License 2.0 5 votes vote down vote up
@Test
public void test_single_id_generation()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);
    } finally {
        factory.shutdownAll();
    }
}
 
Example #20
Source File: BasicTestCase.java    From snowcast with Apache License 2.0 5 votes vote down vote up
@Test
public void test_id_generation_in_reattached_state()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        assertNotNull(sequencer);
        assertNotNull(sequencer.next());

        // Detach the node and free the currently used logical node ID
        sequencer.detachLogicalNode();

        try {
            // Must fail since we're in detached state!
            sequencer.next();
            fail();
        } catch (SnowcastStateException e) {
            // Expected, so ignore
        }

        // Re-attach the node and assign a free logical node ID
        sequencer.attachLogicalNode();

        assertNotNull(sequencer.next());
    } finally {
        factory.shutdownAll();
    }
}
 
Example #21
Source File: MultiNodeTestCase.java    From snowcast with Apache License 2.0 5 votes vote down vote up
@Test
public void test_id_generation_in_reattached_state()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(2);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();
    factory.newHazelcastInstance();

    try {
        String sequencerName = generateKeyNotOwnedBy(hazelcastInstance);
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast, sequencerName);

        assertNotNull(sequencer);
        assertNotNull(sequencer.next());

        // Detach the node and free the currently used logical node ID
        sequencer.detachLogicalNode();

        try {
            // Must fail since we're in detached state!
            sequencer.next();
            fail();
        } catch (SnowcastStateException e) {
            // Expected, so ignore
        }

        // Re-attach the node and assign a free logical node ID
        sequencer.attachLogicalNode();

        assertNotNull(sequencer.next());
    } finally {
        factory.shutdownAll();
    }
}
 
Example #22
Source File: SnowcastSequenceUtilsTestCase.java    From snowcast with Apache License 2.0 5 votes vote down vote up
@Test
public void test_comparator_first_higher_by_counter()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        int boundedNodeCount = calculateBoundedMaxLogicalNodeCount(SnowcastConstants.DEFAULT_MAX_LOGICAL_NODES_13_BITS);
        int shifting = calculateLogicalNodeShifting(boundedNodeCount);
        long sequence1 = generateSequenceId(10000, 1, 2, shifting);
        long sequence2 = generateSequenceId(10000, 1, 1, shifting);

        Comparator<Long> comparator = SnowcastSequenceUtils.snowcastSequenceComparator(sequencer);

        assertEquals(1, comparator.compare(sequence1, sequence2));
    } finally {
        factory.shutdownAll();
    }
}
 
Example #23
Source File: ActionTest.java    From foxtrot with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setupClass() throws Exception {
    hazelcastInstance = new TestHazelcastInstanceFactory(1).newHazelcastInstance(new Config());
    elasticsearchConnection = ElasticsearchTestUtils.getConnection();
    DateTimeZone.setDefault(DateTimeZone.forID("Asia/Kolkata"));
    mapper = new ObjectMapper();
    HazelcastConnection hazelcastConnection = Mockito.mock(HazelcastConnection.class);
    EmailConfig emailConfig = new EmailConfig();
    emailConfig.setHost("127.0.0.1");
    when(hazelcastConnection.getHazelcast()).thenReturn(hazelcastInstance);
    when(hazelcastConnection.getHazelcastConfig()).thenReturn(hazelcastInstance.getConfig());
    CardinalityConfig cardinalityConfig = new CardinalityConfig("true", String.valueOf(ElasticsearchUtils.DEFAULT_SUB_LIST_SIZE));

    TestUtils.ensureIndex(elasticsearchConnection, TableMapStore.TABLE_META_INDEX);
    TestUtils.ensureIndex(elasticsearchConnection, DistributedTableMetadataManager.CARDINALITY_CACHE_INDEX);
    ElasticsearchUtils.initializeMappings(elasticsearchConnection.getClient());
    tableMetadataManager = new DistributedTableMetadataManager(hazelcastConnection, elasticsearchConnection, mapper, cardinalityConfig);
    tableMetadataManager.start();

    tableMetadataManager.save(Table.builder()
                                      .name(TestUtils.TEST_TABLE_NAME)
                                      .ttl(30)
                                      .build());
    List<IndexerEventMutator> mutators = Lists.newArrayList(new LargeTextNodeRemover(mapper,
                                                                                     TextNodeRemoverConfiguration.builder().build()));
    DataStore dataStore = TestUtils.getDataStore();
    queryStore = new ElasticsearchQueryStore(tableMetadataManager, elasticsearchConnection, dataStore, mutators, mapper, cardinalityConfig);
    cacheManager = new CacheManager(new DistributedCacheFactory(hazelcastConnection, mapper, new CacheConfig()));
    AnalyticsLoader analyticsLoader = new AnalyticsLoader(tableMetadataManager, dataStore, queryStore,
            elasticsearchConnection, cacheManager, mapper, new ElasticsearchTuningConfig());
    analyticsLoader.start();
    ExecutorService executorService = Executors.newFixedThreadPool(1);
    queryExecutor = new QueryExecutor(analyticsLoader, executorService, Collections.singletonList(new ResponseCacheUpdater(cacheManager)));
}
 
Example #24
Source File: MultiNodeTestCase.java    From snowcast with Apache License 2.0 4 votes vote down vote up
@Test
public void test_distribute_destroy_node3()
        throws Exception {

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(3);
    HazelcastInstance hazelcastInstance1 = factory.newHazelcastInstance();
    HazelcastInstance hazelcastInstance2 = factory.newHazelcastInstance();
    HazelcastInstance hazelcastInstance3 = factory.newHazelcastInstance();

    try {
        // Build the custom epoch
        SnowcastEpoch epoch = buildEpoch();

        String sequencerName = generateKeyOwnedBy(hazelcastInstance2);
        Snowcast snowcast1 = SnowcastSystem.snowcast(hazelcastInstance1);
        final SnowcastSequencer sequencer1 = buildSnowcastSequencer(snowcast1, sequencerName, epoch);

        assertNotNull(sequencer1);
        assertNotNull(sequencer1.next());

        Snowcast snowcast2 = SnowcastSystem.snowcast(hazelcastInstance2);
        final SnowcastSequencer sequencer2 = buildSnowcastSequencer(snowcast2, sequencerName, epoch);

        assertNotNull(sequencer2);
        assertNotNull(sequencer2.next());

        Snowcast snowcast3 = SnowcastSystem.snowcast(hazelcastInstance3);
        final SnowcastSequencer sequencer3 = buildSnowcastSequencer(snowcast3, sequencerName, epoch);

        assertNotNull(sequencer3);
        assertNotNull(sequencer3.next());

        assertNotEquals(sequencer1, sequencer2);
        assertNotEquals(sequencer1, sequencer3);
        assertNotEquals(sequencer2, sequencer3);

        sequencer1.next();
        sequencer2.next();
        sequencer3.next();

        snowcast3.destroySequencer(sequencer3);

        assertTrueEventually(new AssertTask() {
            @Override
            public void run()
                    throws Exception {

                assertEquals(SnowcastSequenceState.Destroyed, sequencer1.getSequencerState());
                assertEquals(SnowcastSequenceState.Destroyed, sequencer2.getSequencerState());
                assertEquals(SnowcastSequenceState.Destroyed, sequencer3.getSequencerState());
            }
        });

    } finally {
        factory.shutdownAll();
    }
}
 
Example #25
Source File: DistributedTableMetadataManagerTest.java    From foxtrot with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setupClass() throws Exception {
    hazelcastInstance = new TestHazelcastInstanceFactory(1).newHazelcastInstance(new Config());
    elasticsearchConnection = ElasticsearchTestUtils.getConnection();
    ElasticsearchUtils.initializeMappings(elasticsearchConnection.getClient());
}
 
Example #26
Source File: ElasticsearchQueryStoreTest.java    From foxtrot with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setupClass() throws Exception {
    hazelcastInstance = new TestHazelcastInstanceFactory(1).newHazelcastInstance(new Config());
    elasticsearchConnection = ElasticsearchTestUtils.getConnection();
    ElasticsearchUtils.initializeMappings(elasticsearchConnection.getClient());
}
 
Example #27
Source File: QueryExecutorTest.java    From foxtrot with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setupClass() throws Exception {
    hazelcastInstance = new TestHazelcastInstanceFactory(1).newHazelcastInstance(new Config());
    elasticsearchConnection = ElasticsearchTestUtils.getConnection();
}
 
Example #28
Source File: HazelcastEventStoreTest.java    From spring-boot-admin with Apache License 2.0 4 votes vote down vote up
@Override
protected InstanceEventStore createStore(int maxLogSizePerAggregate) {
	HazelcastInstance hazelcast = new TestHazelcastInstanceFactory(1).newHazelcastInstance();
	return new HazelcastEventStore(maxLogSizePerAggregate, hazelcast.getMap("testList"));
}
 
Example #29
Source File: SequencerBackupTestCase.java    From snowcast with Apache License 2.0 4 votes vote down vote up
@Test
public void test_simple_backup_create_sequencer_definition_non_owner() {
    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(2);
    HazelcastInstance hazelcastInstance1 = factory.newHazelcastInstance();
    HazelcastInstance hazelcastInstance2 = factory.newHazelcastInstance();

    try {
        final String sequencerName = generateKeyOwnedBy(hazelcastInstance1);

        // Build the custom epoch
        SnowcastEpoch epoch = buildEpoch();

        Snowcast snowcast1 = SnowcastSystem.snowcast(hazelcastInstance1);
        Snowcast snowcast2 = SnowcastSystem.snowcast(hazelcastInstance2);

        InternalSequencer sequencer2 = (InternalSequencer) buildSnowcastSequencer(snowcast2, sequencerName, epoch);
        InternalSequencer sequencer1 = (InternalSequencer) buildSnowcastSequencer(snowcast1, sequencerName, epoch);

        NodeSequencerService sequencerService1 = (NodeSequencerService) sequencer1.getSequencerService();
        NodeSequencerService sequencerService2 = (NodeSequencerService) sequencer2.getSequencerService();

        PartitionService partitionService = hazelcastInstance1.getPartitionService();
        int partitionId = partitionService.getPartition(sequencerName).getPartitionId();

        final SequencerPartition partition1 = sequencerService1.getSequencerPartition(partitionId);
        final SequencerPartition partition2 = sequencerService2.getSequencerPartition(partitionId);

        assertTrueEventually(new AssertTask() {
            @Override
            public void run()
                    throws Exception {

                SequencerDefinition sequencerDefinition1 = partition1.getSequencerDefinition(sequencerName);
                SequencerDefinition sequencerDefinition2 = partition2.getSequencerDefinition(sequencerName);

                assertEquals(sequencerDefinition1, sequencerDefinition2);
            }
        });
    } finally {
        factory.shutdownAll();
    }
}
 
Example #30
Source File: SequencerBackupTestCase.java    From snowcast with Apache License 2.0 4 votes vote down vote up
@Test
public void test_simple_backup_create_sequencer_definition_owner() {
    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(2);
    HazelcastInstance hazelcastInstance1 = factory.newHazelcastInstance();
    HazelcastInstance hazelcastInstance2 = factory.newHazelcastInstance();

    try {
        final String sequencerName = generateKeyOwnedBy(hazelcastInstance1);

        // Build the custom epoch
        SnowcastEpoch epoch = buildEpoch();

        Snowcast snowcast1 = SnowcastSystem.snowcast(hazelcastInstance1);
        Snowcast snowcast2 = SnowcastSystem.snowcast(hazelcastInstance2);

        InternalSequencer sequencer1 = (InternalSequencer) buildSnowcastSequencer(snowcast1, sequencerName, epoch);
        InternalSequencer sequencer2 = (InternalSequencer) buildSnowcastSequencer(snowcast2, sequencerName, epoch);

        NodeSequencerService sequencerService1 = (NodeSequencerService) sequencer1.getSequencerService();
        NodeSequencerService sequencerService2 = (NodeSequencerService) sequencer2.getSequencerService();

        PartitionService partitionService = hazelcastInstance1.getPartitionService();
        int partitionId = partitionService.getPartition(sequencerName).getPartitionId();

        final SequencerPartition partition1 = sequencerService1.getSequencerPartition(partitionId);
        final SequencerPartition partition2 = sequencerService2.getSequencerPartition(partitionId);

        assertTrueEventually(new AssertTask() {
            @Override
            public void run()
                    throws Exception {

                SequencerDefinition sequencerDefinition1 = partition1.getSequencerDefinition(sequencerName);
                SequencerDefinition sequencerDefinition2 = partition2.getSequencerDefinition(sequencerName);

                assertEquals(sequencerDefinition1, sequencerDefinition2);
            }
        });
    } finally {
        factory.shutdownAll();
    }
}