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 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 intnum_read_loopsprotected longread_sleepprotected 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, 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.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.intgetInfoWriterMaxWritesAfterView()longgetInfoWriterSleepTime()java.lang.StringgetLocation()protected voidhandleView(View new_view, View old_view, boolean coord_changed)voidinit()Called after a protocol has been created and before the 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)booleanregisterShutdownHook()FILE_PINGregisterShutdownHook(boolean r)protected voidremove(java.lang.String clustername, Address addr)protected voidremoveAll(java.lang.String clustername)Removes all files for the given cluster namebooleanremoveAllDataOnViewChange()FILE_PINGremoveAllDataOnViewChange(boolean r)booleanremoveOldCoordsOnViewChange()FILE_PINGremoveOldCoordsOnViewChange(boolean r)voidresetStats()FILE_PINGsetInfoWriterMaxWritesAfterView(int i)FILE_PINGsetInfoWriterSleepTime(long i)FILE_PINGsetLocation(java.lang.String l)protected voidstartInfoWriter()voidstop()Called on aJChannel.disconnect(); stops work (e.g.protected voidstopInfoWriter()booleanupdateStoreOnViewChange()FILE_PINGupdateStoreOnViewChange(boolean u)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)booleanwriteDataOnFind()FILE_PINGwriteDataOnFind(boolean w)voidwriteInfo()-
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
-
num_read_loops
protected int num_read_loops
-
read_sleep
protected long read_sleep
-
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.ExceptionDescription copied from class:ProtocolCalled 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:ProtocolCalled on aJChannel.disconnect(); stops work (e.g. by closing multicast socket). Will be called from top to bottom.
-
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()
-
-