| 1 | package diskCacheV111.poolManager ; |
| 2 | |
| 3 | import java.util.Collection; |
| 4 | import java.util.Iterator; |
| 5 | import java.util.Map; |
| 6 | import java.util.NoSuchElementException; |
| 7 | import java.util.Set; |
| 8 | |
| 9 | import diskCacheV111.pools.PoolV2Mode; |
| 10 | import diskCacheV111.vehicles.StorageInfo; |
| 11 | import java.net.UnknownHostException; |
| 12 | |
| 13 | public interface PoolSelectionUnit { |
| 14 | |
| 15 | /** |
| 16 | * data flow direction. Supported modes are: |
| 17 | * <pre> |
| 18 | * READ - read cached file from a pool |
| 19 | * WRITE - write a new file into a pool |
| 20 | * CACHE - get a file from a tape |
| 21 | * P2P - internal pool 2 pool transfer |
| 22 | * ANY - any of above |
| 23 | * </pre> |
| 24 | */ |
| 25 | public enum DirectionType { |
| 26 | READ, |
| 27 | WRITE, |
| 28 | CACHE, |
| 29 | P2P, |
| 30 | ANY, |
| 31 | } |
| 32 | |
| 33 | public interface SelectionLink { |
| 34 | public String getName() ; |
| 35 | public Iterator<SelectionPool> pools() ; |
| 36 | public String getTag() ; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Encapsulates information about a pool. The information is |
| 41 | * updated periodically. Due to the distributed nature of dCache, |
| 42 | * the information may be outdated. |
| 43 | */ |
| 44 | public interface SelectionPool |
| 45 | { |
| 46 | public String getName(); |
| 47 | |
| 48 | /** |
| 49 | * Returns the time in milliseconds since the last heartbeat |
| 50 | * from the pool. |
| 51 | */ |
| 52 | public long getActive(); |
| 53 | |
| 54 | /** |
| 55 | * Sets whether the pool is active or not. This is also used to |
| 56 | * deliver a hearbeat, i.e. calling this method with an |
| 57 | * argument of 'true' will reset the heartbeat counter. |
| 58 | */ |
| 59 | public void setActive(boolean active); |
| 60 | |
| 61 | /** |
| 62 | * Returns true if the pool has been marked as read-only in the |
| 63 | * pool manager. Notice that this is not the same as whether |
| 64 | * the pool can actually write, as there are other places that |
| 65 | * a pool can be marked read-only. |
| 66 | */ |
| 67 | public boolean isReadOnly(); |
| 68 | /** |
| 69 | * Sets the read-only flag. |
| 70 | */ |
| 71 | public void setReadOnly(boolean rdOnly); |
| 72 | |
| 73 | /** |
| 74 | * Returns true if the pool is enabled. This is the case if no |
| 75 | * operations of the pool have been disabled. |
| 76 | */ |
| 77 | public boolean isEnabled() ; |
| 78 | |
| 79 | /** |
| 80 | * Sets the ID of the pool. Used to detect when a pool was |
| 81 | * restarted. Returns true if and only if the serial ID was changed. |
| 82 | */ |
| 83 | public boolean setSerialId(long serialId); |
| 84 | |
| 85 | /** |
| 86 | * Returns true if the pool is marked as active. This is |
| 87 | * normally the case if a heartbeat has been received within |
| 88 | * the last five minutes. Notice that this is unrelated to |
| 89 | * isEnabled(), e.g., a disabled pool can be active. |
| 90 | */ |
| 91 | public boolean isActive(); |
| 92 | |
| 93 | /** |
| 94 | * Sets the pool mode. The pool mode defines which operations |
| 95 | * are enabled at the pool. |
| 96 | */ |
| 97 | public void setPoolMode(PoolV2Mode mode); |
| 98 | |
| 99 | /** |
| 100 | * Returns the pool mode. |
| 101 | * |
| 102 | * @see setPoolMode |
| 103 | */ |
| 104 | public PoolV2Mode getPoolMode(); |
| 105 | |
| 106 | /** |
| 107 | * Returns whether the pool can perform read operations. |
| 108 | */ |
| 109 | public boolean canRead(); |
| 110 | |
| 111 | /** |
| 112 | * Returns whether the pool can perform write operations. |
| 113 | */ |
| 114 | public boolean canWrite(); |
| 115 | |
| 116 | /** |
| 117 | * Returns whether the pool can perform stage files from tape |
| 118 | * operations. |
| 119 | */ |
| 120 | public boolean canReadFromTape(); |
| 121 | |
| 122 | /** |
| 123 | * Returns whether the pool can perform serve files for P2P |
| 124 | * operations. |
| 125 | */ |
| 126 | public boolean canReadForP2P(); |
| 127 | |
| 128 | /** Returns the names of attached HSM instances. */ |
| 129 | public Set<String> getHsmInstances(); |
| 130 | |
| 131 | /** Sets the set of names of attached HSM instances. */ |
| 132 | public void setHsmInstances(Set<String> hsmInstances); |
| 133 | } |
| 134 | |
| 135 | public interface SelectionLinkGroup { |
| 136 | public String getName() ; |
| 137 | public void add(SelectionLink link); |
| 138 | public boolean remove(SelectionLink link); |
| 139 | Collection<SelectionLink> links(); |
| 140 | void attribute(String attribute, String value, boolean replace); |
| 141 | Set<String> attribute(String attribute); |
| 142 | void removeAttribute(String attribute, String value); |
| 143 | Map<String, Set<String>> attributes(); |
| 144 | |
| 145 | void setCustodialAllowed(boolean isAllowed); |
| 146 | void setOutputAllowed(boolean isAllowed); |
| 147 | void setReplicaAllowed(boolean isAllowed); |
| 148 | void setOnlineAllowed(boolean isAllowed); |
| 149 | void setNearlineAllowed(boolean isAllowed); |
| 150 | |
| 151 | public boolean isCustodialAllowed(); |
| 152 | public boolean isOutputAllowed(); |
| 153 | public boolean isReplicaAllowed(); |
| 154 | public boolean isOnlineAllowed(); |
| 155 | public boolean isNearlineAllowed(); |
| 156 | } |
| 157 | public SelectionPool getPool( String poolName ) ; |
| 158 | public SelectionPool getPool( String poolName , boolean create ) ; |
| 159 | public SelectionLink getLinkByName( String linkName ) throws NoSuchElementException ; |
| 160 | public PoolPreferenceLevel [] |
| 161 | match( DirectionType type, String net , String protocol, |
| 162 | StorageInfo info, String linkGroup ) ; |
| 163 | public String [] getActivePools() ; |
| 164 | public String [] getDefinedPools( boolean enabledOnly ) ; |
| 165 | public String getVersion() ; |
| 166 | public String getNetIdentifier( String address ) throws UnknownHostException; |
| 167 | public String getProtocolUnit( String protocolUnitName ) ; |
| 168 | public SelectionLinkGroup getLinkGroupByName(String linkGroupName) throws NoSuchElementException ; |
| 169 | public String [] getLinkGroups(); |
| 170 | public String [] getLinksByGroupName(String linkGroupName) throws NoSuchElementException ; |
| 171 | public Collection<SelectionPool> getPoolsByPoolGroup(String poolGroup) throws NoSuchElementException; |
| 172 | } |