use of org.apache.geode.management.ManagementException in project geode by apache.
the class MemberMBeanBridge method backupMember.
/**
* backs up all the disk to the targeted directory
*
* @param targetDirPath path of the directory where back up is to be taken
* @return array of DiskBackup results which might get aggregated at Managing node Check the
* validity of this mbean call. When does it make sense to backup a single member of a
* gemfire system in isolation of the other members?
*/
public DiskBackupResult[] backupMember(String targetDirPath) {
if (cache != null) {
Collection<DiskStore> diskStores = cache.listDiskStoresIncludingRegionOwned();
for (DiskStore store : diskStores) {
store.flush();
}
}
DiskBackupResult[] diskBackUpResult = null;
File targetDir = new File(targetDirPath);
if (cache == null) {
return null;
} else {
try {
BackupManager manager = cache.startBackup(cache.getInternalDistributedSystem().getDistributedMember());
boolean abort = true;
Set<PersistentID> existingDataStores;
Set<PersistentID> successfulDataStores;
try {
existingDataStores = manager.prepareBackup();
abort = false;
} finally {
successfulDataStores = manager.finishBackup(targetDir, null, /* TODO rishi */
abort);
}
diskBackUpResult = new DiskBackupResult[existingDataStores.size()];
int j = 0;
for (PersistentID id : existingDataStores) {
if (successfulDataStores.contains(id)) {
diskBackUpResult[j] = new DiskBackupResult(id.getDirectory(), false);
} else {
diskBackUpResult[j] = new DiskBackupResult(id.getDirectory(), true);
}
j++;
}
} catch (IOException e) {
throw new ManagementException(e);
}
}
return diskBackUpResult;
}
use of org.apache.geode.management.ManagementException in project geode by apache.
the class ManagementAdapter method handleAsyncEventQueueRemoval.
/**
* Handles AsyncEventQueue Removal
*
* @param queue The AsyncEventQueue being removed
*/
public void handleAsyncEventQueueRemoval(AsyncEventQueue queue) throws ManagementException {
if (!isServiceInitialised("handleAsyncEventQueueRemoval")) {
return;
}
ObjectName asycnEventQueueMBeanName = MBeanJMXAdapter.getAsycnEventQueueMBeanName(internalCache.getDistributedSystem().getDistributedMember(), queue.getId());
AsyncEventQueueMBean bean;
try {
bean = (AsyncEventQueueMBean) service.getLocalAsyncEventQueueMXBean(queue.getId());
if (bean == null) {
return;
}
} catch (ManagementException e) {
// If no bean found its a NO-OP
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
return;
}
bean.stopMonitor();
service.unregisterMBean(asycnEventQueueMBeanName);
Notification notification = new Notification(JMXNotificationType.ASYNC_EVENT_QUEUE_CLOSED, memberSource, SequenceNumber.next(), System.currentTimeMillis(), ManagementConstants.ASYNC_EVENT_QUEUE_CLOSED_PREFIX + queue.getId());
memberLevelNotifEmitter.sendNotification(notification);
}
use of org.apache.geode.management.ManagementException in project geode by apache.
the class ManagementAdapter method handleManagerStart.
/**
* Handles all the distributed mbean creation part when a Manager is started
*/
public void handleManagerStart() throws ManagementException {
if (!isServiceInitialised("handleManagerStart")) {
return;
}
MBeanJMXAdapter jmxAdapter = service.getJMXAdapter();
Map<ObjectName, Object> registeredMBeans = jmxAdapter.getLocalGemFireMBean();
DistributedSystemBridge dsBridge = new DistributedSystemBridge(service);
this.aggregator = new MBeanAggregator(dsBridge);
// register the aggregator for Federation framework to use
service.addProxyListener(aggregator);
/*
* get the local member mbean as it need to be provided to aggregator first
*/
MemberMXBean localMember = service.getMemberMXBean();
ObjectName memberObjectName = MBeanJMXAdapter.getMemberMBeanName(InternalDistributedSystem.getConnectedInstance().getDistributedMember());
FederationComponent addedComp = service.getLocalManager().getFedComponents().get(memberObjectName);
service.afterCreateProxy(memberObjectName, MemberMXBean.class, localMember, addedComp);
for (ObjectName objectName : registeredMBeans.keySet()) {
if (objectName.equals(memberObjectName)) {
continue;
}
Object object = registeredMBeans.get(objectName);
ObjectInstance instance;
try {
instance = mbeanServer.getObjectInstance(objectName);
String className = instance.getClassName();
Class cls = ClassLoadUtil.classFromName(className);
Type[] intfTyps = cls.getGenericInterfaces();
FederationComponent newObj = service.getLocalManager().getFedComponents().get(objectName);
for (Type intfTyp1 : intfTyps) {
Class intfTyp = (Class) intfTyp1;
service.afterCreateProxy(objectName, intfTyp, object, newObj);
}
} catch (InstanceNotFoundException e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed in Registering distributed mbean ");
}
throw new ManagementException(e);
} catch (ClassNotFoundException e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed in Registering distributed mbean");
}
throw new ManagementException(e);
}
}
}
use of org.apache.geode.management.ManagementException in project geode by apache.
the class SizeExportLogsFunction method execute.
@Override
public void execute(final FunctionContext context) {
try {
InternalCache cache = GemFireCacheImpl.getInstance();
DistributionConfig config = cache.getInternalDistributedSystem().getConfig();
Args args = (Args) context.getArguments();
long diskAvailable = getDiskAvailable(config);
long estimatedSize = estimateLogFileSize(cache.getMyId(), config.getLogFile(), config.getStatisticArchiveFile(), args);
BytesToString bytesToString = new BytesToString();
if (estimatedSize == 0 || estimatedSize < diskAvailable) {
context.getResultSender().lastResult(Arrays.asList(estimatedSize));
} else {
StringBuilder sb = new StringBuilder().append("Estimated disk space required (").append(bytesToString.of(estimatedSize)).append(") to consolidate logs on member ").append(cache.getName()).append(" will exceed available disk space (").append(bytesToString.of(diskAvailable)).append(")");
// FileTooBigException
context.getResultSender().sendException(new ManagementException(sb.toString()));
}
} catch (Exception e) {
e.printStackTrace();
LOGGER.error(e.getMessage());
context.getResultSender().sendException(e);
}
}
use of org.apache.geode.management.ManagementException in project geode by apache.
the class ManagementAdapter method handleDiskRemoval.
/**
* Handles DiskStore Removal
*
* @param disk
*/
public void handleDiskRemoval(DiskStore disk) throws ManagementException {
if (!isServiceInitialised("handleDiskRemoval")) {
return;
}
ObjectName diskStoreMBeanName = MBeanJMXAdapter.getDiskStoreMBeanName(internalCache.getDistributedSystem().getDistributedMember(), disk.getName());
DiskStoreMBean bean;
try {
bean = (DiskStoreMBean) service.getLocalDiskStoreMBean(disk.getName());
if (bean == null) {
return;
}
} catch (ManagementException e) {
// If no bean found its a NO-OP
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
return;
}
bean.stopMonitor();
service.unregisterMBean(diskStoreMBeanName);
Notification notification = new Notification(JMXNotificationType.DISK_STORE_CLOSED, memberSource, SequenceNumber.next(), System.currentTimeMillis(), ManagementConstants.DISK_STORE_CLOSED_PREFIX + disk.getName());
memberLevelNotifEmitter.sendNotification(notification);
memberMBeanBridge.removeDiskStore(disk);
}
Aggregations