Search in sources :

Example 1 with AdminException

use of org.apache.geode.admin.AdminException in project geode by apache.

the class ConnectionNotificationFilterImpl method initializeHelperMbean.

private void initializeHelperMbean() {
    try {
        memberInfoWithStatsMBean = new MemberInfoWithStatsMBean(this);
        MBeanServer mbs = getMBeanServer();
        mbs.registerMBean(memberInfoWithStatsMBean, memberInfoWithStatsMBean.getObjectName());
    /*
       * We are not re-throwing these exceptions as failure create/register the GemFireTypesWrapper
       * will not stop the Agent from working. But we are logging it as it could be an indication of
       * some problem. Also not creating Localized String for the exception.
       */
    } catch (OperationsException e) {
        logger.info(LocalizedMessage.create(LocalizedStrings.AgentImpl_FAILED_TO_INITIALIZE_MEMBERINFOWITHSTATSMBEAN), e);
    } catch (MBeanRegistrationException e) {
        logger.info(LocalizedMessage.create(LocalizedStrings.AgentImpl_FAILED_TO_INITIALIZE_MEMBERINFOWITHSTATSMBEAN), e);
    } catch (AdminException e) {
        logger.info(LocalizedMessage.create(LocalizedStrings.AgentImpl_FAILED_TO_INITIALIZE_MEMBERINFOWITHSTATSMBEAN), e);
    }
}
Also used : AdminException(org.apache.geode.admin.AdminException) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer) OperationsException(javax.management.OperationsException)

Example 2 with AdminException

use of org.apache.geode.admin.AdminException in project geode by apache.

the class RemoteGemFireVM method getBridgeInfo.

public AdminBridgeServer getBridgeInfo(CacheInfo cache, int bridgeRef) throws AdminException {
    BridgeServerRequest request = BridgeServerRequest.createForInfo(cache, bridgeRef);
    BridgeServerResponse response = (BridgeServerResponse) sendAndWait(request);
    if (response.getException() != null) {
        Exception ex = response.getException();
        throw new AdminException(ex.getMessage(), ex);
    } else {
        return response.getBridgeInfo();
    }
}
Also used : AdminException(org.apache.geode.admin.AdminException) AdminException(org.apache.geode.admin.AdminException) OperationCancelledException(org.apache.geode.admin.OperationCancelledException)

Example 3 with AdminException

use of org.apache.geode.admin.AdminException in project geode by apache.

the class RemoteGemFireVM method createSubregion.

public Region createSubregion(CacheInfo c, String parentPath, String regionPath, RegionAttributes attrs) throws AdminException {
    RegionResponse resp = (RegionResponse) sendAndWait(RegionRequest.createForCreateSubregion(c, parentPath, regionPath, attrs));
    Exception ex = resp.getException();
    if (ex != null) {
        throw new AdminException(LocalizedStrings.RemoteGemFireVM_WHILE_CREATING_SUBREGION_0_OF_1.toLocalizedString(new Object[] { regionPath, parentPath }), ex);
    } else {
        return resp.getRegion(this);
    }
}
Also used : AdminException(org.apache.geode.admin.AdminException) AdminException(org.apache.geode.admin.AdminException) OperationCancelledException(org.apache.geode.admin.OperationCancelledException)

Example 4 with AdminException

use of org.apache.geode.admin.AdminException in project geode by apache.

the class IncrementalBackupDUnitTest method testMissingBaseline.

/**
   * Successful if all members perform a full backup when they share the baseline directory and it
   * is missing.
   */
@Test
public void testMissingBaseline() throws Exception {
    /*
     * Get the member ID for VM 1 and perform a baseline.
     */
    String memberId = getMemberId(Host.getHost(0).getVM(1));
    assertBackupStatus(performBaseline());
    /*
     * Find all of the member's oplogs in the baseline (*.crf,*.krf,*.drf)
     */
    Collection<File> memberBaselineOplogs = FileUtils.listFiles(getBackupDirForMember(getBaselineDir(), memberId), new RegexFileFilter(OPLOG_REGEX), DirectoryFileFilter.DIRECTORY);
    assertFalse(memberBaselineOplogs.isEmpty());
    List<String> memberBaselineOplogNames = new LinkedList<>();
    TransformUtils.transform(memberBaselineOplogs, memberBaselineOplogNames, TransformUtils.fileNameTransformer);
    /*
     * Custom incremental backup callable that retrieves the current baseline before deletion.
     */
    SerializableCallable callable = new SerializableCallable("Backup all members.") {

        private final File baselineDir = getBaselineBackupDir();

        @Override
        public Object call() {
            AdminDistributedSystem adminDS = null;
            try {
                DistributedSystemConfig config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
                adminDS = AdminDistributedSystemFactory.getDistributedSystem(config);
                adminDS.connect();
                return adminDS.backupAllMembers(getIncrementalDir(), this.baselineDir);
            } catch (AdminException e) {
                throw new RuntimeException(e);
            } finally {
                if (adminDS != null) {
                    adminDS.disconnect();
                }
            }
        }
    };
    /*
     * Do an incremental after deleting the baseline. It should discover that the baseline is gone
     * and backup all of the operation logs that are in the baseline.
     */
    FileUtils.deleteDirectory(getBaselineDir());
    Host.getHost(0).getVM(1).invoke(callable);
    /*
     * Find all of the member's oplogs in the incremental (*.crf,*.krf,*.drf)
     */
    Collection<File> memberIncrementalOplogs = FileUtils.listFiles(getBackupDirForMember(getIncrementalDir(), memberId), new RegexFileFilter(OPLOG_REGEX), DirectoryFileFilter.DIRECTORY);
    assertFalse(memberIncrementalOplogs.isEmpty());
    List<String> memberIncrementalOplogNames = new LinkedList<>();
    TransformUtils.transform(memberIncrementalOplogs, memberIncrementalOplogNames, TransformUtils.fileNameTransformer);
    /*
     * Assert that all of the baseline operation logs are in the incremental backup. If so, then the
     * missing baseline was discovered by the incremental backup process.
     */
    for (String oplog : memberBaselineOplogNames) {
        assertTrue(memberIncrementalOplogNames.contains(oplog));
    }
}
Also used : AdminException(org.apache.geode.admin.AdminException) DistributedSystemConfig(org.apache.geode.admin.DistributedSystemConfig) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) RegexFileFilter(org.apache.commons.io.filefilter.RegexFileFilter) File(java.io.File) LinkedList(java.util.LinkedList) AdminDistributedSystem(org.apache.geode.admin.AdminDistributedSystem) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Test(org.junit.Test)

Example 5 with AdminException

use of org.apache.geode.admin.AdminException in project geode by apache.

the class IncrementalBackupDUnitTest method incremental2.

/**
   * Invokes {@link AdminDistributedSystem#backupAllMembers(File, File)} on a member.
   * 
   * @param vm a member of the distributed system.
   * @return a status of the backup operation.
   */
private BackupStatus incremental2(VM vm) {
    return (BackupStatus) vm.invoke(new SerializableCallable("Backup all members.") {

        @Override
        public Object call() {
            DistributedSystemConfig config;
            AdminDistributedSystem adminDS = null;
            try {
                config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
                adminDS = AdminDistributedSystemFactory.getDistributedSystem(config);
                adminDS.connect();
                return adminDS.backupAllMembers(getIncremental2Dir(), getIncrementalBackupDir());
            } catch (AdminException e) {
                throw new RuntimeException(e);
            } finally {
                if (adminDS != null) {
                    adminDS.disconnect();
                }
            }
        }
    });
}
Also used : AdminException(org.apache.geode.admin.AdminException) DistributedSystemConfig(org.apache.geode.admin.DistributedSystemConfig) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) AdminDistributedSystem(org.apache.geode.admin.AdminDistributedSystem) BackupStatus(org.apache.geode.admin.BackupStatus)

Aggregations

AdminException (org.apache.geode.admin.AdminException)16 DistributedSystemConfig (org.apache.geode.admin.DistributedSystemConfig)8 AdminDistributedSystem (org.apache.geode.admin.AdminDistributedSystem)7 OperationCancelledException (org.apache.geode.admin.OperationCancelledException)6 Set (java.util.Set)4 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)4 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)4 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 BackupStatus (org.apache.geode.admin.BackupStatus)3 PersistentID (org.apache.geode.cache.persistence.PersistentID)3 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)3 Host (org.apache.geode.test.dunit.Host)3 VM (org.apache.geode.test.dunit.VM)3 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)3 Cache (org.apache.geode.cache.Cache)2 Region (org.apache.geode.cache.Region)2 DiskRegion (org.apache.geode.internal.cache.DiskRegion)2