use of org.apache.geode.internal.cache.persistence.PersistentMemberPattern in project geode by apache.
the class ClusterConfigurationStatusRetriever method fromLocator.
public static String fromLocator(String locatorHostName, int locatorPort) throws ClassNotFoundException, IOException {
final StringBuilder buffer = new StringBuilder();
try {
final InetAddress networkAddress = InetAddress.getByName(locatorHostName);
InetSocketAddress inetSockAddr = new InetSocketAddress(networkAddress, locatorPort);
TcpClient client = new TcpClient();
SharedConfigurationStatusResponse statusResponse = (SharedConfigurationStatusResponse) client.requestToServer(inetSockAddr, new SharedConfigurationStatusRequest(), 10000, true);
for (int i = 0; i < NUM_ATTEMPTS_FOR_SHARED_CONFIGURATION_STATUS; i++) {
if (statusResponse.getStatus().equals(org.apache.geode.management.internal.configuration.domain.SharedConfigurationStatus.STARTED) || statusResponse.getStatus().equals(org.apache.geode.management.internal.configuration.domain.SharedConfigurationStatus.NOT_STARTED)) {
statusResponse = (SharedConfigurationStatusResponse) client.requestToServer(inetSockAddr, new SharedConfigurationStatusRequest(), 10000, true);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// Swallow the exception
}
} else {
break;
}
}
switch(statusResponse.getStatus()) {
case RUNNING:
buffer.append("\nCluster configuration service is up and running.");
break;
case STOPPED:
buffer.append("\nCluster configuration service failed to start , please check the log file for errors.");
break;
case WAITING:
buffer.append("\nCluster configuration service is waiting for other locators with newer shared configuration data.");
Set<PersistentMemberPattern> pmpSet = statusResponse.getOtherLocatorInformation();
if (!pmpSet.isEmpty()) {
buffer.append("\nThis locator might have stale cluster configuration data.");
buffer.append("\nFollowing locators contain potentially newer cluster configuration data");
for (PersistentMemberPattern pmp : pmpSet) {
buffer.append("\nHost : ").append(pmp.getHost());
buffer.append("\nDirectory : ").append(pmp.getDirectory());
}
} else {
buffer.append("\nPlease check the log file for errors");
}
break;
case UNDETERMINED:
buffer.append("\nUnable to determine the status of shared configuration service, please check the log file");
break;
case NOT_STARTED:
buffer.append("\nCluster configuration service has not been started yet");
break;
case STARTED:
buffer.append("\nCluster configuration service has been started, but its not running yet");
break;
}
} catch (Exception e) {
// TODO fix this once Trac Bug #50513 gets fixed
// NOTE this ClassCastException occurs if the a plain text TCP/IP connection is used to
// connect to a Locator
// configured with SSL.
Gfsh.getCurrentInstance().logToFile(String.format("Failed to get the status of the Shared Configuration Service running on Locator (%1$s[%2$d])!", locatorHostName, locatorPort), e);
}
return buffer.toString();
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberPattern in project geode by apache.
the class AdminDistributedSystemImpl method revokePersistentMember.
public static void revokePersistentMember(DM dm, UUID diskStoreID) {
PersistentMemberPattern pattern = new PersistentMemberPattern(diskStoreID);
boolean success = false;
try {
// make sure that the disk store we're revoking is actually missing
boolean found = false;
Set<PersistentID> details = getMissingPersistentMembers(dm);
if (details != null) {
for (PersistentID id : details) {
if (id.getUUID().equals(diskStoreID)) {
found = true;
break;
}
}
}
if (!found) {
return;
}
// Fix for 42607 - verify that the persistent id is not already
// running before revoking it.
PrepareRevokePersistentIDRequest.send(dm, pattern);
success = true;
} finally {
if (success) {
// revoke the persistent member if were able to prepare the revoke
RevokePersistentIDRequest.send(dm, pattern);
} else {
// otherwise, cancel the revoke.
PrepareRevokePersistentIDRequest.cancel(dm, pattern);
}
}
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberPattern in project geode by apache.
the class ShowMissingDiskStoresFunctionJUnitTest method testExecuteReturnsMissingDiskStores.
@Test
public void testExecuteReturnsMissingDiskStores() throws Throwable {
ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction();
List<?> results = null;
when(cache.getPersistentMemberManager()).thenReturn(memberManager);
// Fake missing disk-stores
Set<PersistentMemberID> regions1 = new HashSet<PersistentMemberID>();
regions1.add(new PersistentMemberID(new DiskStoreID(), InetAddress.getLocalHost(), "/diskStore1", 1L, (short) 1));
regions1.add(new PersistentMemberID(new DiskStoreID(), InetAddress.getLocalHost(), "/diskStore2", 2L, (short) 2));
Map<String, Set<PersistentMemberID>> mapMember1 = new HashMap<String, Set<PersistentMemberID>>();
;
mapMember1.put("member1", regions1);
when(memberManager.getWaitingRegions()).thenReturn(mapMember1);
smdsFunc.execute(context);
results = resultSender.getResults();
assertNotNull(results);
assertEquals(1, results.size());
Set<?> detailSet = (Set<?>) results.get(0);
assertEquals(2, detailSet.toArray().length);
assertTrue(detailSet.toArray()[0] instanceof PersistentMemberPattern);
assertTrue(detailSet.toArray()[1] instanceof PersistentMemberPattern);
// Results are not sorted so verify results in either order
if (((PersistentMemberPattern) detailSet.toArray()[0]).getDirectory().equals("/diskStore1")) {
assertEquals("/diskStore2", ((PersistentMemberPattern) detailSet.toArray()[1]).getDirectory());
} else if (((PersistentMemberPattern) detailSet.toArray()[0]).getDirectory().equals("/diskStore2")) {
assertEquals("/diskStore1", ((PersistentMemberPattern) detailSet.toArray()[1]).getDirectory());
} else {
fail("Incorrect missing colocated region results");
}
}
use of org.apache.geode.internal.cache.persistence.PersistentMemberPattern in project geode by apache.
the class ShowMissingDiskStoresFunctionJUnitTest method testExecuteReturnsMissingStoresAndRegions.
@Test
public void testExecuteReturnsMissingStoresAndRegions() throws Throwable {
ShowMissingDiskStoresFunction smdsFunc = new ShowMissingDiskStoresFunction();
List<?> results = null;
when(cache.getPersistentMemberManager()).thenReturn(memberManager);
// Fake missing disk-stores
Set<PersistentMemberID> regions1 = new HashSet<PersistentMemberID>();
regions1.add(new PersistentMemberID(new DiskStoreID(), InetAddress.getLocalHost(), "/diskStore1", 1L, (short) 1));
regions1.add(new PersistentMemberID(new DiskStoreID(), InetAddress.getLocalHost(), "/diskStore2", 2L, (short) 2));
Map<String, Set<PersistentMemberID>> mapMember1 = new HashMap<String, Set<PersistentMemberID>>();
;
mapMember1.put("member1", regions1);
when(memberManager.getWaitingRegions()).thenReturn(mapMember1);
// Fake missing colocated regions
Set<PartitionedRegion> prs = new HashSet<PartitionedRegion>();
prs.add(pr1);
prs.add(pr2);
List<String> missing1 = new ArrayList<String>(Arrays.asList("child1", "child2"));
when(cache.getPartitionedRegions()).thenReturn(prs);
when(pr1.getMissingColocatedChildren()).thenReturn(missing1);
when(pr1.getFullPath()).thenReturn("/pr1");
smdsFunc.execute(context);
results = resultSender.getResults();
assertEquals(2, results.size());
for (Object result : results) {
Set<?> detailSet = (Set<?>) result;
if (detailSet.toArray()[0] instanceof PersistentMemberPattern) {
assertEquals(2, detailSet.toArray().length);
assertTrue(detailSet.toArray()[1] instanceof PersistentMemberPattern);
// Results are not sorted so verify results in either order
if (((PersistentMemberPattern) detailSet.toArray()[0]).getDirectory().equals("/diskStore1")) {
assertEquals("/diskStore2", ((PersistentMemberPattern) detailSet.toArray()[1]).getDirectory());
} else if (((PersistentMemberPattern) detailSet.toArray()[0]).getDirectory().equals("/diskStore2")) {
assertEquals("/diskStore1", ((PersistentMemberPattern) detailSet.toArray()[1]).getDirectory());
} else {
fail("Incorrect missing colocated region results");
}
} else if (detailSet.toArray()[0] instanceof ColocatedRegionDetails) {
assertEquals(2, detailSet.toArray().length);
assertTrue(detailSet.toArray()[1] instanceof ColocatedRegionDetails);
assertEquals("/pr1", ((ColocatedRegionDetails) detailSet.toArray()[0]).getParent());
assertEquals("/pr1", ((ColocatedRegionDetails) detailSet.toArray()[1]).getParent());
// Results are not sorted so verify results in either order
if (((ColocatedRegionDetails) detailSet.toArray()[0]).getChild().equals("child1")) {
assertEquals("child2", ((ColocatedRegionDetails) detailSet.toArray()[1]).getChild());
} else if (((ColocatedRegionDetails) detailSet.toArray()[0]).getChild().equals("child2")) {
assertEquals("child1", ((ColocatedRegionDetails) detailSet.toArray()[1]).getChild());
} else {
fail("Incorrect missing colocated region results");
}
} else {
fail("Unexpected result type: " + detailSet.toArray()[0].getClass());
}
}
}
Aggregations