com.sleepycat.je.rep.ReplicationConfig Java Examples
The following examples show how to use
com.sleepycat.je.rep.ReplicationConfig.
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: BDBHAVirtualHostNodeTestHelper.java From qpid-broker-j with Apache License 2.0 | 5 votes |
public Map<String, Object> createNodeAttributes(String nodeName, String groupName, String address, String helperAddress, String helperNodeNode, int... ports) throws Exception { Map<String, Object> node1Attributes = new HashMap<>(); node1Attributes.put(BDBHAVirtualHostNode.ID, UUID.randomUUID()); node1Attributes.put(BDBHAVirtualHostNode.TYPE, BDBHAVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE); node1Attributes.put(BDBHAVirtualHostNode.NAME, nodeName); node1Attributes.put(BDBHAVirtualHostNode.GROUP_NAME, groupName); node1Attributes.put(BDBHAVirtualHostNode.ADDRESS, address); node1Attributes.put(BDBHAVirtualHostNode.HELPER_ADDRESS, helperAddress); node1Attributes.put(BDBHAVirtualHostNode.STORE_PATH, getMessageStorePath() + File.separator + nodeName); if (address.equals(helperAddress)) { node1Attributes.put(BDBHAVirtualHostNode.PERMITTED_NODES, getPermittedNodes(ports)); } else { node1Attributes.put(BDBHAVirtualHostNode.HELPER_NODE_NAME, helperNodeNode); } Map<String, String> context = new HashMap<>(); context.put(ReplicationConfig.REPLICA_ACK_TIMEOUT, "2 s"); context.put(ReplicationConfig.INSUFFICIENT_REPLICAS_TIMEOUT, "2 s"); if (ports != null) { String bluePrint = getBlueprint(); node1Attributes.put(AbstractVirtualHostNode.VIRTUALHOST_INITIAL_CONFIGURATION, bluePrint); } node1Attributes.put(BDBHAVirtualHostNode.CONTEXT, context); return node1Attributes; }
Example #2
Source File: MultiNodeTest.java From qpid-broker-j with Apache License 2.0 | 4 votes |
@Test public void testClusterCannotStartWithIntruder() throws Exception { int intruderPort = new PortHelper().getNextAvailable(Arrays.stream(getBrokerAdmin().getBdbPorts()).max().getAsInt() + 1); String nodeName = "intruder"; String nodeHostPort = getBrokerAdmin().getHost() + ":" + intruderPort; File environmentPathFile = Files.createTempDirectory("qpid-work-intruder").toFile(); try { environmentPathFile.mkdirs(); ReplicationConfig replicationConfig = new ReplicationConfig("test", nodeName, nodeHostPort); replicationConfig.setHelperHosts(getBrokerAdmin().getHelperHostPort()); EnvironmentConfig envConfig = new EnvironmentConfig(); envConfig.setAllowCreate(true); envConfig.setTransactional(true); envConfig.setDurability(new Durability(Durability.SyncPolicy.SYNC, Durability.SyncPolicy.WRITE_NO_SYNC, Durability.ReplicaAckPolicy.SIMPLE_MAJORITY)); final String currentThreadName = Thread.currentThread().getName(); try (ReplicatedEnvironment intruder = new ReplicatedEnvironment(environmentPathFile, replicationConfig, envConfig)) { LOGGER.debug("Intruder started"); } finally { Thread.currentThread().setName(currentThreadName); } Set<Integer> ports = Arrays.stream(getBrokerAdmin().getGroupAmqpPorts()).boxed().collect(Collectors.toSet()); for (int port : ports) { getBrokerAdmin().awaitNodeToAttainAttributeValue(port, BDBHAVirtualHostNode.STATE, State.ERRORED.name()); } getBrokerAdmin().stop(); try { getBrokerAdmin().start(); fail("Cluster cannot start with an intruder node"); } catch (Exception e) { // pass } } finally { FileUtils.delete(environmentPathFile, true); } }
Example #3
Source File: GroupBrokerAdmin.java From qpid-broker-j with Apache License 2.0 | 4 votes |
private GroupMember[] initializeGroupData(final String groupName, final SpawnBrokerAdmin[] admins) { PortHelper helper = new PortHelper(); int[] ports = new int[admins.length]; String[] addresses = new String[admins.length]; int port = -1; for (int i = 0; i < admins.length; i++) { port = i == 0 ? helper.getNextAvailable() : helper.getNextAvailable(port + 1); addresses[i] = HOST + ":" + port; ports[i] = port; } Map<String, String> context = new HashMap<>(); context.put(ReplicationConfig.INSUFFICIENT_REPLICAS_TIMEOUT, "2 s"); context.put(ReplicationConfig.ELECTIONS_PRIMARY_RETRIES, "0"); context.put(AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_CONTEXT_VAR, "{\"type\":\"BDB_HA\"}"); String permitted = objectToJson(addresses); String contextAsString = objectToJson(context); GroupMember[] members = new GroupMember[admins.length]; for (int i = 0; i < admins.length; i++) { String nodeName = "node-" + ports[i]; Map<String, Object> nodeAttributes = new HashMap<>(); nodeAttributes.put(BDBHAVirtualHostNode.GROUP_NAME, groupName); nodeAttributes.put(BDBHAVirtualHostNode.NAME, nodeName); nodeAttributes.put(BDBHAVirtualHostNode.ADDRESS, addresses[i]); nodeAttributes.put(BDBHAVirtualHostNode.TYPE, BDBHAVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE); nodeAttributes.put(BDBHAVirtualHostNode.DEFAULT_VIRTUAL_HOST_NODE, true); nodeAttributes.put(BDBHAVirtualHostNode.HELPER_ADDRESS, addresses[0]); if (i > 0) { nodeAttributes.put(BDBHAVirtualHostNode.HELPER_NODE_NAME, "node-" + ports[0]); } nodeAttributes.put(BDBHAVirtualHostNode.PERMITTED_NODES, permitted); nodeAttributes.put(BDBHAVirtualHostNode.CONTEXT, contextAsString); members[i] = new GroupMember(nodeName, admins[i].getBrokerAddress(BrokerAdmin.PortType.AMQP).getPort(), port, admins[i], nodeAttributes); } return members; }
Example #4
Source File: ReplicatedEnvironmentFacadeTest.java From qpid-broker-j with Apache License 2.0 | 4 votes |
private ReplicatedEnvironmentConfiguration createReplicatedEnvironmentConfiguration(String nodeName, String nodeHostPort, boolean designatedPrimary) { ReplicatedEnvironmentConfiguration node = mock(ReplicatedEnvironmentConfiguration.class); when(node.getName()).thenReturn(nodeName); when(node.getHostPort()).thenReturn(nodeHostPort); when(node.isDesignatedPrimary()).thenReturn(designatedPrimary); when(node.getQuorumOverride()).thenReturn(TEST_ELECTABLE_GROUP_OVERRIDE); when(node.getPriority()).thenReturn(TEST_PRIORITY); when(node.getGroupName()).thenReturn(TEST_GROUP_NAME); when(node.getHelperHostPort()).thenReturn(TEST_NODE_HELPER_HOST_PORT); when(node.getHelperNodeName()).thenReturn(TEST_NODE_NAME); when(node.getFacadeParameter(eq(Integer.class), eq(MASTER_TRANSFER_TIMEOUT_PROPERTY_NAME), anyInt())).thenReturn(60000); when(node.getFacadeParameter(eq(Integer.class), eq(DB_PING_SOCKET_TIMEOUT_PROPERTY_NAME), anyInt())).thenReturn( 10000); when(node.getFacadeParameter(eq(Integer.class), eq(REMOTE_NODE_MONITOR_INTERVAL_PROPERTY_NAME), anyInt())).thenReturn(1000); when(node.getFacadeParameter(eq(Integer.class), eq(REMOTE_NODE_MONITOR_TIMEOUT_PROPERTY_NAME), anyInt())).thenReturn(1000); when(node.getFacadeParameter(eq(Integer.class), eq(ENVIRONMENT_RESTART_RETRY_LIMIT_PROPERTY_NAME), anyInt())).thenReturn(3); when(node.getFacadeParameter(eq(Integer.class), eq(EXECUTOR_SHUTDOWN_TIMEOUT_PROPERTY_NAME), anyInt())).thenReturn(10000); when(node.getFacadeParameter(eq(Integer.class), eq(LOG_HANDLER_CLEANER_PROTECTED_FILES_LIMIT_PROPERTY_NAME), anyInt())).thenReturn(0); when(node.getFacadeParameter(eq(Map.class), any(), eq(JUL_LOGGER_LEVEL_OVERRIDE), any())).thenReturn(Collections.emptyMap()); Map<String, String> repConfig = new HashMap<>(); repConfig.put(ReplicationConfig.REPLICA_ACK_TIMEOUT, "2 s"); repConfig.put(ReplicationConfig.INSUFFICIENT_REPLICAS_TIMEOUT, "2 s"); when(node.getReplicationParameters()).thenReturn(repConfig); when(node.getStorePath()).thenReturn(new File(_storePath, nodeName).getAbsolutePath()); return node; }
Example #5
Source File: BDBHAVirtualHostNodeTest.java From qpid-broker-j with Apache License 2.0 | 4 votes |
@Test public void testCreateAndActivateVirtualHostNode() throws Exception { int node1PortNumber = _portHelper.getNextAvailable(); String helperAddress = "localhost:" + node1PortNumber; String groupName = "group"; String nodeName = "node1"; Map<String, Object> attributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, node1PortNumber); String messageStorePath = (String)attributes.get(BDBHAVirtualHostNode.STORE_PATH); String repStreamTimeout = "2 h"; Map<String,String> context = (Map<String,String>)attributes.get(BDBHAVirtualHostNode.CONTEXT); context.put(ReplicationConfig.REP_STREAM_TIMEOUT, repStreamTimeout); context.put(EnvironmentConfig.ENV_IS_TRANSACTIONAL, "false"); try { _helper.createHaVHN(attributes); fail("Exception was not thrown."); } catch (RuntimeException e) { final boolean condition = e.getCause() instanceof IllegalArgumentException; assertTrue("Unexpected Exception being thrown.", condition); } context.put(EnvironmentConfig.ENV_IS_TRANSACTIONAL, "true"); BDBHAVirtualHostNode<?> node = _helper.createHaVHN(attributes); node.start(); _helper.assertNodeRole(node, NodeRole.MASTER, NodeRole.REPLICA); assertEquals("Unexpected node state", State.ACTIVE, node.getState()); DurableConfigurationStore store = node.getConfigurationStore(); assertNotNull(store); BDBConfigurationStore bdbConfigurationStore = (BDBConfigurationStore) store; ReplicatedEnvironmentFacade environmentFacade = (ReplicatedEnvironmentFacade) bdbConfigurationStore.getEnvironmentFacade(); assertEquals(nodeName, environmentFacade.getNodeName()); assertEquals(groupName, environmentFacade.getGroupName()); assertEquals(helperAddress, environmentFacade.getHostPort()); assertEquals(helperAddress, environmentFacade.getHelperHostPort()); assertEquals("SYNC,NO_SYNC,SIMPLE_MAJORITY", environmentFacade.getMessageStoreDurability().toString()); _helper.awaitForVirtualhost(node); VirtualHost<?> virtualHost = node.getVirtualHost(); assertNotNull("Virtual host child was not added", virtualHost); assertEquals("Unexpected virtual host name", groupName, virtualHost.getName()); assertEquals("Unexpected virtual host store", bdbConfigurationStore.getMessageStore(), virtualHost.getMessageStore()); assertEquals("Unexpected virtual host state", State.ACTIVE, virtualHost.getState()); node.stop(); assertEquals("Unexpected state returned after stop", State.STOPPED, node.getState()); assertEquals("Unexpected state", State.STOPPED, node.getState()); assertNull("Virtual host is not destroyed", node.getVirtualHost()); node.delete(); assertEquals("Unexpected state returned after delete", State.DELETED, node.getState()); assertEquals("Unexpected state", State.DELETED, node.getState()); assertFalse("Store still exists " + messageStorePath, new File(messageStorePath).exists()); }