Package org.jgroups.protocols
Class FILE_PING
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.Discovery
-
- org.jgroups.protocols.FILE_PING
-
- Direct Known Subclasses:
JDBC_PING,RACKSPACE_PING,S3_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 classFILE_PING.InfoWriterClass 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.FilenameFilterfilterprotected java.util.concurrent.Future<?>info_writerprotected intinfo_writer_max_writes_after_viewprotected longinfo_writer_sleep_timeprotected java.lang.Stringlocationprotected intreadsprotected static java.util.regex.Patternregexpprotected booleanregister_shutdown_hookprotected booleanremove_all_data_on_view_changeprotected booleanremove_old_coords_on_view_changeprotected java.io.Fileroot_dirprotected static java.lang.StringSUFFIXprotected booleanupdate_store_on_view_changeprotected booleanwrite_data_on_findprotected intwrites-
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, local_addr, 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, use_ip_addrs, view, WHITESPACE
-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, log, 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.StringaddressToFilename(Address mbr)protected voidcreateRootDir()protected booleandeleteFile(java.io.File file)java.lang.Objectdown(Event evt)An event is to be sent down the stack.voidfindMembers(java.util.List<Address> members, boolean initial_discovery, Responses responses)Fetches information (e.g.java.lang.StringgetLocation()booleangetRemoveAllDataOnViewChange()protected voidhandleView(View new_view, View old_view, boolean coord_changed)voidinit()Called after instance has been created (null constructor) and before protocol is started.booleanisDynamic()booleanisInfoWriterRunning()protected java.util.List<PingData>read(java.io.File file)protected java.util.List<PingData>read(java.io.InputStream in)protected voidreadAll(java.util.List<Address> members, java.lang.String clustername, Responses responses)protected voidremove(java.lang.String clustername, Address addr)protected voidremoveAll(java.lang.String clustername)Removes all files for the given cluster namevoidresetStats()FILE_PINGsetLocation(java.lang.String l)FILE_PINGsetRemoveAllDataOnViewChange(boolean r)protected voidstartInfoWriter()voidstop()This method is called on aJChannel.disconnect().protected voidstopInfoWriter()protected voidwrite(java.util.List<PingData> list, java.io.OutputStream out)protected voidwrite(java.util.List<PingData> list, java.lang.String clustername)protected voidwriteAll()Write information about all of the member to file (only if I'm the coord)protected voidwriteAll(Address[] excluded_mbrs)voidwriteInfo()-
Methods inherited from class org.jgroups.protocols.Discovery
addDiscoveryResponseToCaches, addResponse, addResponse, addressAsString, addToCache, breakOnCoordResponse, breakOnCoordResponse, clearRequestFutures, deserialize, discoveryRequestReceived, discoveryRspExpiryTime, disseminateDiscoveryInformation, dumpCache, findInitialMembersAsString, findMembers, getClusterName, getCurrentCoord, getNumberOfDiscoveryRequestsSent, getView, getViewId, handleConnect, handleDisconnect, handleDiscoveryResponse, invokeFindMembers, isCoord, isMergeRunning, marshal, providedUpServices, readPingData, returnEntireCache, returnEntireCache, sendCacheInformation, sendDiscoveryResponse, serializeWithoutView, setClusterName, staggerTimeout, staggerTimeout, start, startCacheDissemination, up, up, useDiskCache, useDiskCache, weedOutCompletedDiscoveryResponses
-
Methods inherited from class org.jgroups.stack.Protocol
accept, afterCreationHook, destroy, down, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, providedDownServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, up
-
-
-
-
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)
-
getRemoveAllDataOnViewChange
public boolean getRemoveAllDataOnViewChange()
-
setRemoveAllDataOnViewChange
public FILE_PING setRemoveAllDataOnViewChange(boolean r)
-
isInfoWriterRunning
public boolean isInfoWriterRunning()
-
writeInfo
public void writeInfo()
-
init
public void init() throws java.lang.ExceptionDescription copied from class:ProtocolCalled after instance has been created (null constructor) and before protocol is started. Properties are already set. Other protocols are not yet connected and events cannot yet be sent.
-
stop
public void stop()
Description copied from class:ProtocolThis method is called on aJChannel.disconnect(). Stops work (e.g. by closing multicast socket). Will be called from top to bottom. This means that at the time of the method invocation the neighbor protocol below is still working. This method will replace the STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that when this method is called all messages in the down queue will have been flushed
-
resetStats
public void resetStats()
- Overrides:
resetStatsin classDiscovery
-
down
public java.lang.Object down(Event evt)
Description copied from class:ProtocolAn 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:DiscoveryFetches information (e.g. physical address, logical name) for the given member addresses. Needs to add responses to theResponsesobject. IfDiscovery.async_discoveryis true, this method will be called in a separate thread, otherwise the caller's thread will be used.- Specified by:
findMembersin classDiscovery- Parameters:
members- A list of logical addresses (typicallyUUIDs). 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()
-
-