@Override protected void becomePrimary() { for (Gateway gateway : getGateways()) { ((GatewayImpl) gateway).becomePrimary(); } }
public void setSocketReadTimeout(int socketReadTimeout) { synchronized (this.controlLock) { checkRunning(); getLogger().warning(LocalizedStrings.GatewayImpl_GATEWAY_SOCKET_READ_TIMEOUT_DISABLED); // do nothing on purpose... // setSocketReadTimeout is now optional and this impl ignores it // setSocketReadTimeout was causing too many problems because customers // kept using too small of a value } }
@Override public void emergencyClose() { for (Gateway gateway : getGateways()) { ((GatewayImpl) gateway).emergencyClose(); } }
public void addListener(GatewayEventListener listener) throws GatewayException { synchronized (this.controlLock) { checkRunning(); // If endpoints are already defined, throw an exception if (hasEndpoints()) { throw new GatewayException(LocalizedStrings.GatewayImpl_GATEWAY_0_CANNOT_DEFINE_A_LISTENER_BECAUSE_AT_LEAST_ONE_ENDPOINT_IS_ALREADY_DEFINED_BOTH_LISTENERS_AND_ENDPOINTS_CANNOT_BE_DEFINED_FOR_THE_SAME_GATEWAY.toLocalizedString(this._id)); } List newListeners = new ArrayList(this._listeners); newListeners.add(listener); this._listeners = Collections.unmodifiableList(newListeners); } }
if (getStatistics().isClosed()) { setStatistics(new GatewayStats(this._cache.getDistributedSystem(), getGatewayHubId(), getId(), gpi == null ? null : gpi.getStatistics())); if(hasEndpoints()) { for (Iterator i = getEndpoints().iterator(); i.hasNext();) { Endpoint endpoint = (Endpoint)i.next(); buffer.append(endpoint.getId()).append('=').append(endpoint.getHost()) this._proxy = createPool(properties); EndpointManagerImpl emi = (EndpointManagerImpl) this._proxy.getEndpointManager(); emi.setGatewayStats(getStatistics()); GatewayEventProcessor ev = initializeEventProcessor(); setRunning(true); ev.start(); ((GemFireCacheImpl) getCache()).getPdxRegistry().gatewayStarted(this); setRunning(false); throw e; setRunning(false); throw e; this.getLogger().info(LocalizedStrings.SerialGatewaySenderImpl_STARTED__0, this);
.append(getGateway().getGatewayHubId()) .append('_') .append(getGateway().getId()) .append("_EVENT_QUEUE"); String regionName = regionNameBuffer.toString(); if (!getGateway().getPrimary()) { listener = new SecondaryGatewayListener(this); initializeListenerExecutor(); queue = new SingleWriteSingleReadRegionQueue(getGateway().getCache(), regionName, getGateway().getQueueAttributes(), listener, getGateway().getStatistics());
checkRunning(); if (alreadyDefinesEndpoint(id, host, port)) { throw new GatewayException(LocalizedStrings.GatewayImpl_GATEWAY_0_ALREADY_DEFINES_AN_ENDPOINT_EITHER_WITH_ID_1_OR_HOST_2_AND_PORT_3.toLocalizedString( new Object[] {this._id, id, host, Integer.valueOf(port)})); if (!this._usedInParallel && otherGatewayDefinesEndpoint(host, port, otherGateway)) { throw new GatewayException(LocalizedStrings.GatewayImpl_GATEWAY_0_CANNOT_DEFINE_ENDPOINT_HOST_1_AND_PORT_2_BECAUSE_IT_IS_ALREADY_DEFINED_BY_GATEWAY_3.toLocalizedString( new Object[] {this._id, host, Integer.valueOf(port), otherGateway[0]})); if (isConnectingToOwnHub(host, port)) { throw new GatewayException(LocalizedStrings.GatewayImpl_GATEWAY_0_CANNOT_DEFINE_AN_ENDPOINT_TO_ITS_OWN_HUB_HOST_1_AND_PORT_2 .toLocalizedString(new Object[] {this._id, host, Integer.valueOf(port)})); if (hasListeners()) { throw new GatewayException(LocalizedStrings.GatewayImpl_GATEWAY_0_CANNOT_DEFINE_AN_ENDPOINT_BECAUSE_AT_LEAST_ONE_LISTENER_IS_ALREADY_DEFINED_BOTH_LISTENERS_AND_ENDPOINTS_CANNOT_BE_DEFINED_FOR_THE_SAME_GATEWAY .toLocalizedString(this._id));
private void processQueue() { GatewayQueueAttributes gqa = getGateway().getQueueAttributes(); final int batchSize = gqa.getBatchSize(); final int batchTimeInterval = gqa.getBatchTimeInterval(); final int alertThreshold = gqa.getAlertThreshold(); final GatewayStats statistics = getGateway().getStatistics(); List events = null; for (;;) { GatewayImpl.this.getCancelCriterion().checkCancelInProgress(e); continue; // keep trying
if (!getGateway().getPrimary()) { if (!waitForPrimary()) { return; completeFailover(); if (!getGateway().getPrimary()) { getLogger().warning(LocalizedStrings. GatewayImpl_ABOUT_TO_PROCESS_THE_MESSAGE_QUEUE_BUT_NOT_THE_PRIMARY);
GatewayStats statistics = getGateway().getStatistics(); if (getLogger().fineEnabled()) { getLogger().fine(getGateway() + ": Queueing event (" GatewayImpl.this.getCancelCriterion().checkCancelInProgress(e);
getGateway().waitToBecomePrimary(); completeFailover();
public void setSocketBufferSize(int socketBufferSize) { synchronized (this.controlLock) { checkRunning(); this._socketBufferSize = socketBufferSize; } }
private void initializeGateways(int concurrencyLevel) { // Create a GatewayImpl for each of the parallel threads for (int i = 0; i < concurrencyLevel; i++) { Gateway gateway = new GatewayImpl((GatewayHubImpl) getGatewayHub(), getId() + "." + i, true, getStatistics()); getGateways().add(gateway); } StringBuilder builder = new StringBuilder(); for (Iterator<Gateway> i = getGateways().iterator(); i.hasNext();) { Gateway gateway = i.next(); builder.append(gateway.getId()); if (i.hasNext()) { builder.append(", "); } } Object[] args = new Object[] {toString(), concurrencyLevel, builder.toString()}; getLogger().info(LocalizedStrings.GatewayParallel_0_CREATED_1_GATEWAYS_2, args); } }
private void destroyQueuePersistenceFiles() { //Destroy a files of a persistent region ((SingleWriteSingleReadRegionQueue)this._eventQueue).destroyPersistentFiles(getGateway().getCache()); }
private void initializeGateway(GatewayImpl gatewayImpl) { //TODO Dan - make sure that the gateway is already //receiving updates by the time we iterate over the region here. TXStateInterface currentState = suspendTX(); Region<Object, Object> r = getIdToType(); try { for(Map.Entry<Object, Object> typeEntry: r.entrySet()) { EntryEventImpl event = EntryEventImpl.create( (LocalRegion) r, Operation.UPDATE, typeEntry.getKey(), typeEntry.getValue(), new GatewayEventCallbackArgument((Object)null), false, cache.getMyId()); try { event.setEventId(new EventID(cache.getSystem())); gatewayImpl.distribute(EnumListenerEvent.AFTER_UPDATE, event); } finally { event.release(); } } } finally { resumeTX(currentState); } }
public void setQueueAttributes(GatewayQueueAttributes queueAttributes) { synchronized (this.controlLock) { checkRunning(); // See bug 44558. The gateway.stop method has been changed to close the // region. If the previous queue attributes enabled persistence and the // new ones don't, destroy the disk files. Don't use the existing queue // attributes since they may have been modified in place. If the event // processor is null, the gateway has not been started, so there isn't any // way to know the previous state. This method will throw an // IllegalStateException if the previous state is incompatible with the // new state. if (this._eventProcessor != null && ((SingleWriteSingleReadRegionQueue) this._eventProcessor._eventQueue) .isPersistent() && (!queueAttributes.getEnablePersistence())) { this._eventProcessor.destroyQueuePersistenceFiles(); } this._queueAttributes = queueAttributes; } }
public Gateway addGateway(String id, int concurrencyLevel) throws GatewayException { synchronized (this.controlLock) { checkRunning(); AbstractGateway gateway; synchronized (allGatewaysLock) { // If a gateway with the id is already defined, throw an exception if (alreadyDefinesGateway(id)) { throw new GatewayException(LocalizedStrings.GatewayHubImpl_GATEWAYHUB_0_ALREADY_DEFINES_A_GATEWAY_WITH_ID_1.toLocalizedString(new Object[] {this._id, id})); } if (concurrencyLevel < Gateway.DEFAULT_CONCURRENCY_LEVEL) { throw new GatewayException( LocalizedStrings.Gateway_INVALID_CONCURRENCY_LEVEL .toLocalizedString(new Object[] { id, concurrencyLevel })); } gateway = concurrencyLevel > Gateway.DEFAULT_CONCURRENCY_LEVEL ? new GatewayParallelImpl(this, id, concurrencyLevel) : new GatewayImpl(this, id); AbstractGateway snap[] = allGateways; // volatile fetch this.allGateways = (AbstractGateway[]) ArrayUtils.insert(snap, snap.length, gateway); this._gatewayIds.add(id); } this._statistics.incNumberOfGateways(); return gateway; } }