Package org.jgroups.protocols
Class FILE_PING
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.Discovery
-
- org.jgroups.protocols.FILE_PING
-
- All Implemented Interfaces:
Lifecycle
- Direct Known Subclasses:
JDBC_PING
,JDBC_PING2
,RACKSPACE_PING
,SWIFT_PING
public class FILE_PING extends Discovery
Simple discovery protocol which uses a file on shared storage such as an SMB share, NFS mount or S3. The local address information, e.g. UUID and physical addresses mappings are written to the file and the content is read and added to our transport's UUID-PhysicalAddress cache. The design is at doc/design/FILE_PING.txt- Author:
- Bela Ban
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
FILE_PING.InfoWriter
Class which calls writeAll() a few times.-
Nested classes/interfaces inherited from class org.jgroups.protocols.Discovery
Discovery.DiscoveryCacheDisseminationTask
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.io.FilenameFilter
filter
protected java.util.concurrent.Future<?>
info_writer
protected int
info_writer_max_writes_after_view
protected long
info_writer_sleep_time
protected java.lang.String
location
protected int
reads
protected static java.util.regex.Pattern
regexp
protected boolean
register_shutdown_hook
protected boolean
remove_all_data_on_view_change
protected boolean
remove_old_coords_on_view_change
protected java.io.File
root_dir
protected static java.lang.String
SUFFIX
protected boolean
update_store_on_view_change
protected boolean
write_data_on_find
protected int
writes
-
Fields inherited from class org.jgroups.protocols.Discovery
async_discovery, async_discovery_use_separate_thread_per_request, break_on_coord_rsp, cluster_name, current_coord, discovery_req_futures, discovery_rsp_callback, discovery_rsp_expiry_time, is_coord, is_leaving, is_server, max_members_in_discovery_request, max_rank_to_reply, num_discovery_requests, num_discovery_runs, ping_responses, return_entire_cache, send_cache_on_join, sends_can_block, stagger_timeout, timer, transport, transport_supports_multicasting, use_disk_cache, view, WHITESPACE
-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description FILE_PING()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.lang.String
addressToFilename(Address mbr)
protected void
createRootDir()
protected boolean
deleteFile(java.io.File file)
java.lang.Object
down(Event evt)
An event is to be sent down the stack.void
findMembers(java.util.List<Address> members, boolean initial_discovery, Responses responses)
Fetches information (e.g.int
getInfoWriterMaxWritesAfterView()
long
getInfoWriterSleepTime()
java.lang.String
getLocation()
protected void
handleView(View new_view, View old_view, boolean coord_changed)
void
init()
Called after a protocol has been created and before the protocol is started.boolean
isDynamic()
boolean
isInfoWriterRunning()
protected java.util.List<PingData>
read(java.io.File file)
protected java.util.List<PingData>
read(java.io.InputStream in)
protected void
readAll(java.util.List<Address> members, java.lang.String clustername, Responses responses)
boolean
registerShutdownHook()
FILE_PING
registerShutdownHook(boolean r)
protected void
remove(java.lang.String clustername, Address addr)
protected void
removeAll(java.lang.String clustername)
Removes all files for the given cluster nameboolean
removeAllDataOnViewChange()
FILE_PING
removeAllDataOnViewChange(boolean r)
boolean
removeOldCoordsOnViewChange()
FILE_PING
removeOldCoordsOnViewChange(boolean r)
void
resetStats()
FILE_PING
setInfoWriterMaxWritesAfterView(int i)
FILE_PING
setInfoWriterSleepTime(long i)
FILE_PING
setLocation(java.lang.String l)
protected void
startInfoWriter()
void
stop()
Called on aJChannel.disconnect()
; stops work (e.g.protected void
stopInfoWriter()
boolean
updateStoreOnViewChange()
FILE_PING
updateStoreOnViewChange(boolean u)
protected void
write(java.util.List<PingData> list, java.io.OutputStream out)
protected void
write(java.util.List<PingData> list, java.lang.String clustername)
protected void
writeAll()
Write information about all of the member to file (only if I'm the coord)protected void
writeAll(Address[] excluded_mbrs)
boolean
writeDataOnFind()
FILE_PING
writeDataOnFind(boolean w)
void
writeInfo()
-
Methods inherited from class org.jgroups.protocols.Discovery
addDiscoveryResponseToCaches, addResponse, addResponse, addressAsString, addToCache, breakOnCoordResponse, breakOnCoordResponse, callFindMembersInAllDiscoveryProtocols, clearRequestFutures, deserialize, discoveryRequestReceived, discoveryRspExpiryTime, disseminateDiscoveryInformation, dumpCache, findInitialMembersAsString, findMembers, findTopmostDiscoveryProtocol, getClusterName, getCurrentCoord, getNumberOfDiscoveryRequestsSent, getView, getViewId, handle, handleConnect, handleDisconnect, handleDiscoveryResponse, handleDiscoveryResponse, isCoord, isMergeRunning, marshal, marshal, marshal, print, providedUpServices, readPingData, returnEntireCache, returnEntireCache, sendCacheInformation, sendCacheOnJoin, sendCacheOnJoin, sendDiscoveryResponse, sendDiscoveryResponse, serializeWithoutView, setClusterName, staggerTimeout, staggerTimeout, start, startCacheDissemination, up, up, up, useDiskCache, useDiskCache, weedOutCompletedDiscoveryResponses
-
Methods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, destroy, down, down, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, toString
-
-
-
-
Field Detail
-
SUFFIX
protected static final java.lang.String SUFFIX
- See Also:
- Constant Field Values
-
regexp
protected static final java.util.regex.Pattern regexp
-
location
protected java.lang.String location
-
remove_old_coords_on_view_change
protected boolean remove_old_coords_on_view_change
-
remove_all_data_on_view_change
protected boolean remove_all_data_on_view_change
-
info_writer_max_writes_after_view
protected int info_writer_max_writes_after_view
-
info_writer_sleep_time
protected long info_writer_sleep_time
-
write_data_on_find
protected boolean write_data_on_find
-
register_shutdown_hook
protected boolean register_shutdown_hook
-
update_store_on_view_change
protected boolean update_store_on_view_change
-
writes
protected int writes
-
reads
protected int reads
-
root_dir
protected java.io.File root_dir
-
filter
protected static final java.io.FilenameFilter filter
-
info_writer
protected java.util.concurrent.Future<?> info_writer
-
-
Method Detail
-
getLocation
public java.lang.String getLocation()
-
setLocation
public FILE_PING setLocation(java.lang.String l)
-
removeAllDataOnViewChange
public boolean removeAllDataOnViewChange()
-
removeAllDataOnViewChange
public FILE_PING removeAllDataOnViewChange(boolean r)
-
removeOldCoordsOnViewChange
public boolean removeOldCoordsOnViewChange()
-
removeOldCoordsOnViewChange
public FILE_PING removeOldCoordsOnViewChange(boolean r)
-
getInfoWriterMaxWritesAfterView
public int getInfoWriterMaxWritesAfterView()
-
setInfoWriterMaxWritesAfterView
public FILE_PING setInfoWriterMaxWritesAfterView(int i)
-
getInfoWriterSleepTime
public long getInfoWriterSleepTime()
-
setInfoWriterSleepTime
public FILE_PING setInfoWriterSleepTime(long i)
-
writeDataOnFind
public boolean writeDataOnFind()
-
writeDataOnFind
public FILE_PING writeDataOnFind(boolean w)
-
registerShutdownHook
public boolean registerShutdownHook()
-
registerShutdownHook
public FILE_PING registerShutdownHook(boolean r)
-
updateStoreOnViewChange
public boolean updateStoreOnViewChange()
-
updateStoreOnViewChange
public FILE_PING updateStoreOnViewChange(boolean u)
-
isInfoWriterRunning
public boolean isInfoWriterRunning()
-
writeInfo
public void writeInfo()
-
init
public void init() throws java.lang.Exception
Description copied from class:Protocol
Called after a protocol has been created and before the protocol is started. Attributes are already set. Other protocols are not yet connected and events cannot yet be sent.
-
stop
public void stop()
Description copied from class:Protocol
Called on aJChannel.disconnect()
; stops work (e.g. by closing multicast socket). Will be called from top to bottom.
-
resetStats
public void resetStats()
- Overrides:
resetStats
in classDiscovery
-
down
public java.lang.Object down(Event evt)
Description copied from class:Protocol
An event is to be sent down the stack. A protocol may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the protocol may need to add a header to it (or do nothing at all) before sending it down the stack usingdown_prot.down()
.
-
findMembers
public void findMembers(java.util.List<Address> members, boolean initial_discovery, Responses responses)
Description copied from class:Discovery
Fetches information (e.g. physical address, logical name) for the given member addresses. Needs to add responses to theResponses
object. IfDiscovery.async_discovery
is true, this method will be called in a separate thread, otherwise the caller's thread will be used.- Specified by:
findMembers
in classDiscovery
- Parameters:
members
- A list of logical addresses (typicallyUUID
s). If null, then information for all members is fetchedinitial_discovery
- Set to true if this is for the initial membership discovery. Some protocols (e.g. file based ones) may return only the information for the coordinator(s).responses
- The list to which responses should be added
-
addressToFilename
protected static java.lang.String addressToFilename(Address mbr)
-
createRootDir
protected void createRootDir()
-
remove
protected void remove(java.lang.String clustername, Address addr)
-
removeAll
protected void removeAll(java.lang.String clustername)
Removes all files for the given cluster name
-
readAll
protected void readAll(java.util.List<Address> members, java.lang.String clustername, Responses responses)
-
read
protected java.util.List<PingData> read(java.io.File file) throws java.lang.Exception
- Throws:
java.lang.Exception
-
read
protected java.util.List<PingData> read(java.io.InputStream in)
-
writeAll
protected void writeAll()
Write information about all of the member to file (only if I'm the coord)
-
writeAll
protected void writeAll(Address[] excluded_mbrs)
-
write
protected void write(java.util.List<PingData> list, java.lang.String clustername)
-
write
protected void write(java.util.List<PingData> list, java.io.OutputStream out) throws java.lang.Exception
-
deleteFile
protected boolean deleteFile(java.io.File file)
-
startInfoWriter
protected void startInfoWriter()
-
stopInfoWriter
protected void stopInfoWriter()
-
-