use of org.apache.geode.InternalGemFireException in project geode by apache.
the class DistributionManager method create.
/**
* Creates a new distribution manager and discovers the other members of the distributed system.
* Note that it does not check to see whether or not this VM already has a distribution manager.
*
* @param system The distributed system to which this distribution manager will send messages.
*/
public static DistributionManager create(InternalDistributedSystem system) {
DistributionManager distributionManager = null;
try {
int vmKind;
if (Boolean.getBoolean(InternalLocator.FORCE_LOCATOR_DM_TYPE)) {
// if this DM is starting for a locator, set it to be a locator DM
vmKind = LOCATOR_DM_TYPE;
} else if (isDedicatedAdminVM) {
vmKind = ADMIN_ONLY_DM_TYPE;
} else {
vmKind = NORMAL_DM_TYPE;
}
RemoteTransportConfig transport = new RemoteTransportConfig(system.getConfig(), vmKind);
transport.setIsReconnectingDS(system.isReconnectingDS());
transport.setOldDSMembershipInfo(system.oldDSMembershipInfo());
long start = System.currentTimeMillis();
distributionManager = new DistributionManager(system, transport);
distributionManager.assertDistributionManagerType();
{
InternalDistributedMember id = distributionManager.getDistributionManagerId();
if (!"".equals(id.getName())) {
for (InternalDistributedMember m : (List<InternalDistributedMember>) distributionManager.getViewMembers()) {
if (m.equals(id)) {
// SO once we find ourself break out of this loop.
break;
}
if (id.getName().equals(m.getName())) {
if (distributionManager.getMembershipManager().verifyMember(m, "member is using the name of " + id)) {
throw new IncompatibleSystemException("Member " + id + " could not join this distributed system because the existing member " + m + " used the same name. Set the \"name\" gemfire property to a unique value.");
}
}
}
}
// add ourselves
distributionManager.addNewMember(id);
// ShutdownException could be thrown here
distributionManager.selectElder();
}
// Send out a StartupMessage to the other members.
StartupOperation op = new StartupOperation(distributionManager, transport);
try {
if (!distributionManager.sendStartupMessage(op, true)) {
// we're the first one.
if (distributionManager.getOtherDistributionManagerIds().size() == 0) {
logger.info(LocalizedMessage.create(LocalizedStrings.DistributionManager_DIDNT_HEAR_BACK_FROM_ANY_OTHER_SYSTEM_I_AM_THE_FIRST_ONE));
} else if (transport.isMcastEnabled()) {
// perform a multicast ping test
if (!distributionManager.testMulticast()) {
logger.warn(LocalizedMessage.create(LocalizedStrings.DistributionManager_RECEIVED_NO_STARTUP_RESPONSES_BUT_OTHER_MEMBERS_EXIST_MULTICAST_IS_NOT_RESPONSIVE));
}
}
}
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
// This is ALWAYS bad; don't consult a CancelCriterion.
throw new InternalGemFireException(LocalizedStrings.DistributionManager_INTERRUPTED_WHILE_WAITING_FOR_FIRST_STARTUPRESPONSEMESSAGE.toLocalizedString(), ex);
} catch (IncompatibleSystemException ex) {
logger.fatal(ex.getMessage(), ex);
throw ex;
} finally {
distributionManager.readyToSendMsgs();
}
if (logger.isInfoEnabled()) {
long delta = System.currentTimeMillis() - start;
Object[] logArgs = new Object[] { distributionManager.getDistributionManagerId(), transport, Integer.valueOf(distributionManager.getOtherDistributionManagerIds().size()), distributionManager.getOtherDistributionManagerIds(), (logger.isInfoEnabled(LogMarker.DM) ? " (VERBOSE, took " + delta + " ms)" : ""), ((distributionManager.getDMType() == ADMIN_ONLY_DM_TYPE) ? " (admin only)" : (distributionManager.getDMType() == LOCATOR_DM_TYPE) ? " (locator)" : "") };
logger.info(LogMarker.DM, LocalizedMessage.create(LocalizedStrings.DistributionManager_DISTRIBUTIONMANAGER_0_STARTED_ON_1_THERE_WERE_2_OTHER_DMS_3_4_5, logArgs));
MembershipLogger.logStartup(distributionManager.getDistributionManagerId());
}
return distributionManager;
} catch (RuntimeException r) {
if (distributionManager != null) {
if (logger.isDebugEnabled()) {
logger.debug("cleaning up incompletely started DistributionManager due to exception", r);
}
distributionManager.uncleanShutdown(true);
}
throw r;
}
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class HARegionQueue method reinitializeRegion.
/**
* reinitialize the queue, presumably pulling current information from seconaries
*/
public void reinitializeRegion() {
InternalCache cache = this.region.getCache();
String regionName = this.region.getName();
this.region.destroyRegion();
Exception problem = null;
try {
createHARegion(regionName, cache);
} catch (IOException e) {
problem = e;
} catch (ClassNotFoundException e) {
problem = e;
}
if (problem != null) {
throw new InternalGemFireException("Problem recreating region queue '" + regionName + "'");
}
try {
this.putGIIDataInRegion();
} catch (InterruptedException e) {
cache.getCancelCriterion().checkCancelInProgress(e);
Thread.currentThread().interrupt();
}
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class CacheXmlGenerator method generate.
/**
* Generates XML for <code>ExpirationAttributes</code>
*/
private void generate(String kind, ExpirationAttributes attrs, CustomExpiry custom) throws SAXException {
if (attrs == null) {
return;
}
handler.startElement("", kind, kind, EMPTY);
int timeout = attrs.getTimeout();
ExpirationAction action = attrs.getAction();
AttributesImpl atts = new AttributesImpl();
atts.addAttribute("", "", TIMEOUT, "", String.valueOf(timeout));
String actionString;
if (action.equals(ExpirationAction.DESTROY)) {
actionString = DESTROY;
} else if (action.equals(ExpirationAction.INVALIDATE)) {
actionString = INVALIDATE;
} else if (action.equals(ExpirationAction.LOCAL_DESTROY)) {
actionString = LOCAL_DESTROY;
} else if (action.equals(ExpirationAction.LOCAL_INVALIDATE)) {
actionString = LOCAL_INVALIDATE;
} else {
throw new InternalGemFireException(LocalizedStrings.CacheXmlGenerator_UNKNOWN_EXPIRATIONACTION_0.toLocalizedString(action));
}
atts.addAttribute("", "", ACTION, "", actionString);
handler.startElement("", EXPIRATION_ATTRIBUTES, EXPIRATION_ATTRIBUTES, atts);
if (custom != null) {
AttributesImpl endAtts = new AttributesImpl();
handler.startElement("", CUSTOM_EXPIRY, CUSTOM_EXPIRY, endAtts);
generate((Declarable) custom, false);
handler.endElement("", CUSTOM_EXPIRY, CUSTOM_EXPIRY);
}
handler.endElement("", EXPIRATION_ATTRIBUTES, EXPIRATION_ATTRIBUTES);
handler.endElement("", kind, kind);
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class CacheXmlParser method startGatewaySender.
private void startGatewaySender(Attributes atts) {
GatewaySenderFactory gatewaySenderFactory = this.cache.createGatewaySenderFactory();
String parallel = atts.getValue(PARALLEL);
if (parallel == null) {
gatewaySenderFactory.setParallel(GatewaySender.DEFAULT_IS_PARALLEL);
} else {
gatewaySenderFactory.setParallel(Boolean.parseBoolean(parallel));
}
// manual-start
String manualStart = atts.getValue(MANUAL_START);
if (manualStart == null) {
gatewaySenderFactory.setManualStart(GatewaySender.DEFAULT_MANUAL_START);
} else {
gatewaySenderFactory.setManualStart(Boolean.parseBoolean(manualStart));
}
// socket-buffer-size
String socketBufferSize = atts.getValue(SOCKET_BUFFER_SIZE);
if (socketBufferSize == null) {
gatewaySenderFactory.setSocketBufferSize(GatewaySender.DEFAULT_SOCKET_BUFFER_SIZE);
} else {
gatewaySenderFactory.setSocketBufferSize(Integer.parseInt(socketBufferSize));
}
// socket-read-timeout
String socketReadTimeout = atts.getValue(SOCKET_READ_TIMEOUT);
if (socketReadTimeout == null) {
gatewaySenderFactory.setSocketReadTimeout(GatewaySender.DEFAULT_SOCKET_READ_TIMEOUT);
} else {
gatewaySenderFactory.setSocketReadTimeout(Integer.parseInt(socketReadTimeout));
}
// batch-conflation
String batchConflation = atts.getValue(ENABLE_BATCH_CONFLATION);
if (batchConflation == null) {
gatewaySenderFactory.setBatchConflationEnabled(GatewaySender.DEFAULT_BATCH_CONFLATION);
} else {
gatewaySenderFactory.setBatchConflationEnabled(Boolean.parseBoolean(batchConflation));
}
// batch-size
String batchSize = atts.getValue(BATCH_SIZE);
if (batchSize == null) {
gatewaySenderFactory.setBatchSize(GatewaySender.DEFAULT_BATCH_SIZE);
} else {
gatewaySenderFactory.setBatchSize(Integer.parseInt(batchSize));
}
// batch-time-interval
String batchTimeInterval = atts.getValue(BATCH_TIME_INTERVAL);
if (batchTimeInterval == null) {
gatewaySenderFactory.setBatchTimeInterval(GatewaySender.DEFAULT_BATCH_TIME_INTERVAL);
} else {
gatewaySenderFactory.setBatchTimeInterval(Integer.parseInt(batchTimeInterval));
}
// enable-persistence
String enablePersistence = atts.getValue(ENABLE_PERSISTENCE);
if (enablePersistence == null) {
gatewaySenderFactory.setPersistenceEnabled(GatewaySender.DEFAULT_PERSISTENCE_ENABLED);
} else {
gatewaySenderFactory.setPersistenceEnabled(Boolean.parseBoolean(enablePersistence));
}
String diskStoreName = atts.getValue(DISK_STORE_NAME);
if (diskStoreName == null) {
gatewaySenderFactory.setDiskStoreName(null);
} else {
gatewaySenderFactory.setDiskStoreName(diskStoreName);
}
String diskSynchronous = atts.getValue(DISK_SYNCHRONOUS);
if (diskSynchronous == null) {
gatewaySenderFactory.setDiskSynchronous(GatewaySender.DEFAULT_DISK_SYNCHRONOUS);
} else {
gatewaySenderFactory.setDiskSynchronous(Boolean.parseBoolean(diskSynchronous));
}
// maximum-queue-memory
String maxQueueMemory = atts.getValue(MAXIMUM_QUEUE_MEMORY);
if (maxQueueMemory == null) {
gatewaySenderFactory.setMaximumQueueMemory(GatewaySender.DEFAULT_MAXIMUM_QUEUE_MEMORY);
} else {
gatewaySenderFactory.setMaximumQueueMemory(Integer.parseInt(maxQueueMemory));
}
String alertThreshold = atts.getValue(ALERT_THRESHOLD);
if (alertThreshold == null) {
gatewaySenderFactory.setAlertThreshold(GatewaySender.DEFAULT_ALERT_THRESHOLD);
} else {
gatewaySenderFactory.setAlertThreshold(Integer.parseInt(alertThreshold));
}
String dispatcherThreads = atts.getValue(DISPATCHER_THREADS);
if (dispatcherThreads == null) {
gatewaySenderFactory.setDispatcherThreads(GatewaySender.DEFAULT_DISPATCHER_THREADS);
} else {
gatewaySenderFactory.setDispatcherThreads(Integer.parseInt(dispatcherThreads));
}
String id = atts.getValue(ID);
String orderPolicy = atts.getValue(ORDER_POLICY);
if (orderPolicy != null) {
try {
gatewaySenderFactory.setOrderPolicy(GatewaySender.OrderPolicy.valueOf(orderPolicy.toUpperCase()));
} catch (IllegalArgumentException e) {
throw new InternalGemFireException(LocalizedStrings.SerialGatewaySender_UNKNOWN_GATEWAY_ORDER_POLICY_0_1.toLocalizedString(new Object[] { id, orderPolicy }));
}
}
String remoteDS = atts.getValue(REMOTE_DISTRIBUTED_SYSTEM_ID);
stack.push(id);
stack.push(remoteDS);
stack.push(gatewaySenderFactory);
// GatewaySender sender = gatewaySenderFactory.create(id, Integer.parseInt(remoteDS));
// stack.push(sender);
}
use of org.apache.geode.InternalGemFireException in project geode by apache.
the class CacheXmlGenerator method generate.
/**
* Generates XML for <code>SubscriptionAttributes</code>
*/
private void generate(SubscriptionAttributes attrs) throws SAXException {
if (attrs == null) {
return;
}
String interestString = null;
InterestPolicy ip = attrs.getInterestPolicy();
AttributesImpl atts = new AttributesImpl();
if (ip.isAll()) {
interestString = ALL;
} else if (ip.isCacheContent()) {
interestString = CACHE_CONTENT;
} else {
throw new InternalGemFireException(LocalizedStrings.CacheXmlGenerator_UNKNOWN_INTERESTPOLICY_0.toLocalizedString(ip));
}
atts.addAttribute("", "", INTEREST_POLICY, "", interestString);
handler.startElement("", SUBSCRIPTION_ATTRIBUTES, SUBSCRIPTION_ATTRIBUTES, atts);
handler.endElement("", SUBSCRIPTION_ATTRIBUTES, SUBSCRIPTION_ATTRIBUTES);
}
Aggregations