com.gemstone.gemfire.cache.util.Gateway Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gemfire-core Show documentation
Show all versions of gemfire-core Show documentation
SnappyData store based off Pivotal GemFireXD
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/
package com.gemstone.gemfire.cache.util;
import java.io.IOException;
import java.util.List;
import com.gemstone.gemfire.cache.GatewayException;
/**
* A Gateway
represents a local proxy for a remote
* WAN (or distributed system).
*
* @since 4.2
*/
public interface Gateway {
/**
* The default buffer size for socket buffers from a sending
* Gateway
to its receiving Gateway
.
*/
public static final int DEFAULT_SOCKET_BUFFER_SIZE = 32768;
/**
* The default amount of time in milliseconds that a socket read between a
* sending Gateway
and its receiving Gateway
will
* block.
*/
public static final int DEFAULT_SOCKET_READ_TIMEOUT = Integer.getInteger("gemfire.cache.gateway.default-socket-read-timeout", 0).intValue();
/**
* The default number of parallel threads dispatching events from one member.
* The member has one logical queue and this many actual physical queues and
* dispatchers dispatching events from those queues. Events will be enqueued
* in the physical queues based on the hashCode of the member id and thread
* id. Per-thread ordering will be maintained. The current value is 1.
*
* @since 6.5.1
*/
public static final int DEFAULT_CONCURRENCY_LEVEL = 1;
/**
* The 'primary' startup policy.
* This setting means that the VM will attempt to become the primary
* GatewayHub
. If it can become the primary
* GatewayHub
, it will. If not, then it will log a warning
* and become a secondary GatewayHub
.
*/
public static final String STARTUP_POLICY_PRIMARY = "primary";
/**
* The order policy. This enum is applicable only when concurrency-level is > 1.
*
* @since 6.5.1
*/
public enum OrderPolicy {
/**
* Indicates that events will be parallelized based on the event's
* originating member and thread
*/
THREAD,
/**
* Indicates that events will be parallelized based on the event's key
*/
KEY,
/** Indicates that events will be parallelized based on the event's:
* - partition (using the PartitionResolver) in the case of a partitioned
* region event
* - key in the case of a replicated region event
*/
PARTITION
}
/**
* Returns this Gateway
's GatewayHub
identifier.
* @return this Gateway
's GatewayHub
identifier.
*/
public String getGatewayHubId();
/**
* Returns this Gateway
's identifier.
* @return this Gateway
's identifier.
*/
public String getId();
/**
* Add an Endpoint
to this Gateway
.
* @param id The id of the endpoint
* @param host The host of the endpoint
* @param port The port that the endpoint is listening on
*
* @throws GatewayException if this Gateway
already defines
* an Endpoint
with this id
*/
public void addEndpoint(String id, String host, int port) throws GatewayException;
/**
* Returns the list of Endpoint
s
* @return the list of Endpoint
s
*/
public List getEndpoints(); // the element of the returned list is the internal Endpoint interface
/**
* Returns whether this Gateway
has Endpoint
s
* @return whether this Gateway
has Endpoint
s
*/
public boolean hasEndpoints();
/**
* Add a GatewayEventListener
to this Gateway
.
* @param listener The GatewayEventListener
to add
*
* @throws GatewayException if this Gateway
already defines
* any Endpoint
s
*
* @since 5.1
*/
public void addListener(GatewayEventListener listener) throws GatewayException;
/**
* Returns the list of GatewayEventListener
s
* @return the list of GatewayEventListener
s
*
* @since 5.1
*/
public List getListeners();
/**
* Returns whether this Gateway
has GatewayEventListener
s
* @return whether this Gateway
has GatewayEventListener
s
*
* @since 5.1
*/
public boolean hasListeners();
/**
* Sets whether to enable early acknowledgement for this Gateway
's
* queue.
* @param earlyAck Whether or not to enable early acknowledgement for
* batches sent from this Gateway
to its corresponding
* Gateway
.
* @throws UnsupportedOperationException because of deprecation
* @deprecated EarlyAck communication is unsafe and no longer supported
*/
@Deprecated
public void setEarlyAck(boolean earlyAck);
/**
* Gets whether to enable early acknowledgement for this Gateway
's
* queue.
* @return whether to enable early acknowledgement for batches sent from this
* Gateway
to its corresponding Gateway
.
* @deprecated EarlyAck communication is unsafe and no longer supported
*/
@Deprecated
public boolean getEarlyAck();
/**
* Sets the buffer size in bytes of the socket connection between this
* Gateway
and its receiving Gateway
. The
* default is 32768 bytes.
*
* @param socketBufferSize The size in bytes of the socket buffer
*
* @since 4.2.1
*/
public void setSocketBufferSize(int socketBufferSize);
/**
* Returns the configured buffer size of the socket connection between this
* Gateway
and its receiving Gateway
. The default
* is 32768 bytes.
* @return the configured buffer size of the socket connection between this
* Gateway
and its receiving Gateway
*
* @since 4.2.1
*/
public int getSocketBufferSize();
/**
* Optional operation.
* Sets the amount of time in milliseconds that a socket read between a
* sending Gateway
and its receiving Gateway
will
* block. The default is 10000 seconds.
*
* @param socketReadTimeout The amount of time to block
*
* @since 4.2.2
*/
public void setSocketReadTimeout(int socketReadTimeout);
/**
* Optional operation.
* Returns the amount of time in milliseconds that a socket read between a
* sending Gateway
and its receiving Gateway
will
* block. The default is 10000 seconds.
* @return the amount of time in milliseconds that a socket read between a
* sending Gateway
and its receiving Gateway
will
* block
*
* @since 4.2.2
*/
public int getSocketReadTimeout();
/**
* Sets the GatewayQueueAttributes
s for this
* Gateway
. Calling setQueueAttributes on a stopped
* Gateway
will destroy the existing queue and create a new
* empty queue.
*
* @param queueAttributes The GatewayQueueAttributes
to use
*/
public void setQueueAttributes(GatewayQueueAttributes queueAttributes);
/**
* Returns the GatewayQueueAttributes
s for this Gateway
* @return the GatewayQueueAttributes
s for this Gateway
*/
public GatewayQueueAttributes getQueueAttributes();
/**
* Starts this Gateway
. Once the hub is running, its
* configuration cannot be changed.
*
* @throws IOException
* If an error occurs while starting the Gateway
*/
public void start() throws IOException;
/**
* Returns whether or not this Gateway
is running
*/
public boolean isRunning();
/**
* Stops this Gateway
. Note that the
* Gateway
can be reconfigured and restarted if
* desired.
*/
public void stop();
/**
* Returns whether or not this Gateway
is connected to its
* remote Gateway
.
*/
public boolean isConnected();
/**
* Returns the number of entries in this Gateway
's queue.
* @return the number of entries in this Gateway
's queue
*/
public int getQueueSize();
/**
* Pauses this Gateway
.
*
* @since 6.0
*/
public void pause();
/**
* Resumes this paused Gateway
.
*
* @since 6.0
*/
public void resume();
/**
* Returns whether or not this Gateway
is running.
*
* @since 6.0
*/
public boolean isPaused();
/**
* An Endpoint
represents a proxy to a remote host
*/
public interface Endpoint {
/** Returns the identifier for this Endpoint
.
*
* @return the identifier for this Endpoint
*/
public String getId();
/** Returns the host for this Endpoint
.
*
* @return the host for this Endpoint
*/
public String getHost();
/** Returns the port for this Endpoint
.
*
* @return the port for this Endpoint
*/
public int getPort();
}
/**
* Returns the concurrency level (number of parallel threads) processing
* GatewayEvent
s
*
* @return the concurrency level (number of parallel threads) processing
* GatewayEvent
s
*
* @see #DEFAULT_CONCURRENCY_LEVEL
* @since 6.5.1
*/
public int getConcurrencyLevel();
/**
* Sets the OrderPolicy
for this Gateway
.
*
* @param orderPolicy
* the OrderPolicy
for this Gateway
*
* @since 6.5.1
*/
public void setOrderPolicy(OrderPolicy orderPolicy);
/**
* Returns the OrderPolicy
for this Gateway
.
*
* @return the OrderPolicy
for this Gateway
*
* @since 6.5.1
*/
public OrderPolicy getOrderPolicy();
}