Coverage Report - org.jscsi.target.settings.Settings
 
Classes in this File Line Coverage Branch Coverage Complexity
Settings
0%
0/71
0%
0/2
1.08
 
 1  
 package org.jscsi.target.settings;
 2  
 
 3  
 /**
 4  
  * Instances of this class contain all session-wide and connection-specific parameters that are either declared by the
 5  
  * initiator or negotiated in the text parameter negotiation stages.
 6  
  * 
 7  
  * @author Andreas Ergenzinger
 8  
  */
 9  
 public final class Settings {
 10  
 
 11  
     /**
 12  
      * The {@link #settingsId} variable allows to compare the age of different {@link Settings} objects - newer
 13  
      * instances have a higher {@link #settingsId}.
 14  
      * <p>
 15  
      * What it is really used for, however, is for determining if the buffered {@link Settings} object, which can be
 16  
      * accessed via {@link ConnectionSettingsNegotiator#getSettings()} is up to date or if it has to be replaced.
 17  
      * 
 18  
      * @see ConnectionSettingsNegotiator#getSettings()
 19  
      * @see SessionSettingsNegotiator#getCurrentSettingsId()
 20  
      */
 21  
     private final long settingsId;
 22  
 
 23  
     // connection parameters
 24  
     /**
 25  
      * The <code>DataDigest</code> parameter.
 26  
      */
 27  
     private final String dataDigest;
 28  
 
 29  
     /**
 30  
      * The <code>HeaderDigest</code> parameter.
 31  
      */
 32  
     private final String headerDigest;
 33  
 
 34  
     /**
 35  
      * The <code>IFMarker</code> parameter.
 36  
      */
 37  
     private final Boolean ifMarker;
 38  
 
 39  
     /**
 40  
      * The <code>IFMarkInt</code> parameter.
 41  
      */
 42  
     private final Integer ifMarkInt;
 43  
 
 44  
     /**
 45  
      * The <code>MaxRecvDataSegmentLength</code> parameter.
 46  
      */
 47  
     private final Integer maxRecvDataSegmentLength;
 48  
 
 49  
     /**
 50  
      * The <code>OFMarker</code> parameter.
 51  
      */
 52  
     private final Boolean ofMarker;
 53  
 
 54  
     /**
 55  
      * The <code>OFMarkInt</code> parameter.
 56  
      */
 57  
     private final Integer ofMarkInt;
 58  
 
 59  
     // session parameters
 60  
 
 61  
     /**
 62  
      * The <code>TargetName</code> parameter
 63  
      */
 64  
     private final String targetName;
 65  
 
 66  
     /**
 67  
      * The <code>DataPDUInOrder</code> parameter.
 68  
      */
 69  
     private final Boolean dataPduInOrder;
 70  
 
 71  
     /**
 72  
      * The <code>DataSequenceInOrder</code> parameter.
 73  
      */
 74  
     private final Boolean dataSequenceInOrder;
 75  
 
 76  
     /**
 77  
      * The <code>DefaultTime2Retain</code> parameter.
 78  
      */
 79  
     private final Integer defaultTime2Retain;
 80  
 
 81  
     /**
 82  
      * The <code>DefaultTime2Wait</code> parameter.
 83  
      */
 84  
     private final Integer defaultTime2Wait;
 85  
 
 86  
     /**
 87  
      * The <code>ErrorRecoveryLevel</code> parameter.
 88  
      */
 89  
     private final Integer errorRecoveryLevel;
 90  
 
 91  
     /**
 92  
      * The <code>FirstBurstLength</code> parameter.
 93  
      */
 94  
     private final Integer firstBurstLength;
 95  
 
 96  
     /**
 97  
      * The <code>ImmediateData</code> parameter.
 98  
      */
 99  
     private final Boolean immediateData;
 100  
 
 101  
     /**
 102  
      * The <code>InitialR2T</code> parameter.
 103  
      */
 104  
     private final Boolean initialR2T;
 105  
 
 106  
     /**
 107  
      * The <code>InitiatorAlias</code> parameter.
 108  
      */
 109  
     private final String initiatorAlias;
 110  
 
 111  
     /**
 112  
      * The <code>InitiatorName</code> parameter.
 113  
      */
 114  
     private final String initiatorName;
 115  
 
 116  
     /**
 117  
      * The <code>MaxBurstLength</code> parameter.
 118  
      */
 119  
     private final Integer maxBurstLength;
 120  
 
 121  
     /**
 122  
      * The <code>MaxConnections</code> parameter.
 123  
      */
 124  
     private final Integer maxConnections;
 125  
 
 126  
     /**
 127  
      * The <code>MaxOutstandingR2T</code> parameter.
 128  
      */
 129  
     private final Integer maxOutstandingR2T;
 130  
 
 131  
     /**
 132  
      * The <code>SessionType</code> parameter.
 133  
      */
 134  
     private final String sessionType;
 135  
 
 136  
     /**
 137  
      * Throws a {@link SettingsException} if the parameter is <code>null</code>.
 138  
      * 
 139  
      * @param member the member variable to check
 140  
      * @throws SettingsException if the parameter is <code>null</code>
 141  
      */
 142  
     private static void checkIfNull (Object member) throws SettingsException {
 143  0
         if (member == null) throw new SettingsException();
 144  0
     }
 145  
 
 146  
     /**
 147  
      * The constructor based on the builder pattern.
 148  
      * 
 149  
      * @param c {@link ConnectionSettingsBuilderComponent} with the current connection-specific parameters
 150  
      * @param s {@link SessionSettingsBuilderComponent} with the current session-wide parameters
 151  
      */
 152  0
     Settings (final ConnectionSettingsBuilderComponent c, final SessionSettingsBuilderComponent s) {
 153  0
         settingsId = s.settingsId;
 154  
         // connection parameters
 155  0
         dataDigest = c.dataDigest;
 156  0
         headerDigest = c.headerDigest;
 157  0
         ifMarker = c.ifMarker;
 158  0
         ifMarkInt = c.ifMarkInt;
 159  0
         maxRecvDataSegmentLength = c.maxRecvDataSegmentLength;
 160  0
         ofMarker = c.ofMarker;
 161  0
         ofMarkInt = c.ofMarkInt;
 162  0
         targetName = c.targetName;
 163  
         // session parameters
 164  
 
 165  0
         dataPduInOrder = s.dataPduInOrder;
 166  0
         dataSequenceInOrder = s.dataSequenceInOrder;
 167  0
         defaultTime2Retain = s.defaultTime2Retain;
 168  0
         defaultTime2Wait = s.defaultTime2Wait;
 169  0
         errorRecoveryLevel = s.errorRecoveryLevel;
 170  0
         firstBurstLength = s.firstBurstLength;
 171  0
         immediateData = s.immediateData;
 172  0
         initialR2T = s.initialR2T;
 173  0
         initiatorAlias = s.initiatorAlias;
 174  0
         initiatorName = s.initiatorName;
 175  0
         maxBurstLength = s.maxBurstLength;
 176  0
         maxConnections = s.maxConnections;
 177  0
         maxOutstandingR2T = s.maxOutstandingR2T;
 178  0
         sessionType = s.sessionType;
 179  0
     }
 180  
 
 181  
     /**
 182  
      * Returns the {@link #settingsId}.
 183  
      * 
 184  
      * @return the {@link #settingsId}
 185  
      */
 186  
     long getSettingsId () {
 187  0
         return settingsId;
 188  
     }
 189  
 
 190  
     /**
 191  
      * Returns the value of the <code>DataDigest</code> parameter.
 192  
      * 
 193  
      * @return the value of the <code>DataDigest</code> parameter
 194  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 195  
      */
 196  
     public String getDataDigest () throws SettingsException {
 197  0
         checkIfNull(dataDigest);
 198  0
         return dataDigest;
 199  
     }
 200  
 
 201  
     /**
 202  
      * Returns the value of the <code>HeaderDigest</code> parameter.
 203  
      * 
 204  
      * @return the value of the <code>HeaderDigest</code> parameter
 205  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 206  
      */
 207  
     public String getHeaderDigest () throws SettingsException {
 208  0
         checkIfNull(headerDigest);
 209  0
         return headerDigest;
 210  
     }
 211  
 
 212  
     /**
 213  
      * Returns the value of the <code>IFMarker</code> parameter.
 214  
      * 
 215  
      * @return the value of the <code>IFMarker</code> parameter
 216  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 217  
      */
 218  
     public boolean getIfMarker () throws SettingsException {
 219  0
         checkIfNull(ifMarker);
 220  0
         return ifMarker;
 221  
     }
 222  
 
 223  
     /**
 224  
      * Returns the value of the <code>IFMarkInt</code> parameter.
 225  
      * 
 226  
      * @return the value of the <code>IFMarkInt</code> parameter
 227  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 228  
      */
 229  
     public int getIfMarkInt () throws SettingsException {
 230  0
         checkIfNull(ifMarkInt);
 231  0
         return ifMarkInt;
 232  
     }
 233  
 
 234  
     /**
 235  
      * Returns the value of the <code>MaxRecvDataSegmentLenght</code> parameter.
 236  
      * 
 237  
      * @return the value of the <code>MaxRecvDataSegmentLenght</code> parameter
 238  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 239  
      */
 240  
     public int getMaxRecvDataSegmentLength () throws SettingsException {
 241  0
         checkIfNull(maxRecvDataSegmentLength);
 242  0
         return maxRecvDataSegmentLength;
 243  
     }
 244  
 
 245  
     /**
 246  
      * Returns the value of the <code>OFMarker</code> parameter.
 247  
      * 
 248  
      * @return the value of the <code>OFMarker</code> parameter
 249  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 250  
      */
 251  
     public boolean getOfMarker () throws SettingsException {
 252  0
         checkIfNull(ofMarker);
 253  0
         return ofMarker;
 254  
     }
 255  
 
 256  
     /**
 257  
      * Returns the value of the <code>OFMarkInt</code> parameter.
 258  
      * 
 259  
      * @return the value of the <code>OFMarkInt</code> parameter
 260  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 261  
      */
 262  
     public int getOfMarkInt () throws SettingsException {
 263  0
         checkIfNull(ofMarkInt);
 264  0
         return ofMarkInt;
 265  
     }
 266  
 
 267  
     /**
 268  
      * Returns the value of the <code>DataPDUInOrder</code> parameter.
 269  
      * 
 270  
      * @return the value of the <code>DataPDUInOrder</code> parameter
 271  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 272  
      */
 273  
     public boolean getDataPduInOrder () throws SettingsException {
 274  0
         checkIfNull(dataPduInOrder);
 275  0
         return dataPduInOrder;
 276  
     }
 277  
 
 278  
     /**
 279  
      * Returns the value of the <code>DataSequenceInOrder</code> parameter.
 280  
      * 
 281  
      * @return the value of the <code>DataSequenceInOrder</code> parameter
 282  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 283  
      */
 284  
     public boolean getDataSequenceInOrder () throws SettingsException {
 285  0
         checkIfNull(dataSequenceInOrder);
 286  0
         return dataSequenceInOrder;
 287  
     }
 288  
 
 289  
     /**
 290  
      * Returns the value of the <code>ErrorRecoveryLevel</code> parameter.
 291  
      * 
 292  
      * @return the value of the <code>ErrorRecoveryLevel</code> parameter
 293  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 294  
      */
 295  
     public int getErrorRecoveryLevel () throws SettingsException {
 296  0
         checkIfNull(errorRecoveryLevel);
 297  0
         return errorRecoveryLevel;
 298  
     }
 299  
 
 300  
     /**
 301  
      * Returns the value of the <code>DefaultTime2Retain</code> parameter.
 302  
      * 
 303  
      * @return the value of the <code>DefaultTime2Retain</code> parameter
 304  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 305  
      */
 306  
     public int getDefaultTime2Retain () throws SettingsException {
 307  0
         checkIfNull(defaultTime2Retain);
 308  0
         return defaultTime2Retain;
 309  
     }
 310  
 
 311  
     /**
 312  
      * Returns the value of the <code>DefaultTime2Wait</code> parameter.
 313  
      * 
 314  
      * @return the value of the <code>DefaultTime2Wait</code> parameter
 315  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 316  
      */
 317  
     public int getDefaultTime2Wait () throws SettingsException {
 318  0
         checkIfNull(defaultTime2Wait);
 319  0
         return defaultTime2Wait;
 320  
     }
 321  
 
 322  
     /**
 323  
      * Returns the value of the <code>FirstBurstLength</code> parameter.
 324  
      * 
 325  
      * @return the value of the <code>FirstBurstLength</code> parameter
 326  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 327  
      */
 328  
     public int getFirstBurstLength () throws SettingsException {
 329  0
         checkIfNull(firstBurstLength);
 330  0
         return firstBurstLength;
 331  
     }
 332  
 
 333  
     /**
 334  
      * Returns the value of the <code>ImmediateData</code> parameter.
 335  
      * 
 336  
      * @return the value of the <code>ImmediateData</code> parameter
 337  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 338  
      */
 339  
     public boolean getImmediateData () throws SettingsException {
 340  0
         checkIfNull(immediateData);
 341  0
         return immediateData;
 342  
     }
 343  
 
 344  
     /**
 345  
      * Returns the value of the <code>InitialR2T</code> parameter.
 346  
      * 
 347  
      * @return the value of the <code>InitialR2T</code> parameter
 348  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 349  
      */
 350  
     public boolean getInitialR2T () throws SettingsException {
 351  0
         checkIfNull(initialR2T);
 352  0
         return initialR2T;
 353  
     }
 354  
 
 355  
     /**
 356  
      * Returns the value of the <code>InitiatorAlias</code> parameter.
 357  
      * 
 358  
      * @return the value of the <code>InitiatorAlias</code> parameter
 359  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 360  
      */
 361  
     public String getInitiatorAlias () throws SettingsException {
 362  0
         checkIfNull(initiatorAlias);
 363  0
         return initiatorAlias;
 364  
     }
 365  
 
 366  
     /**
 367  
      * Returns the value of the <code>InitiatorName</code> parameter.
 368  
      * 
 369  
      * @return the value of the <code>InitiatorName</code> parameter
 370  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 371  
      */
 372  
     public String getInitiatorName () throws SettingsException {
 373  0
         checkIfNull(initiatorName);
 374  0
         return initiatorName;
 375  
     }
 376  
 
 377  
     /**
 378  
      * Returns the value of the <code>MaxBurstLength</code> parameter.
 379  
      * 
 380  
      * @return the value of the <code>MaxBurstLength</code> parameter
 381  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 382  
      */
 383  
     public int getMaxBurstLength () throws SettingsException {
 384  0
         checkIfNull(maxBurstLength);
 385  0
         return maxBurstLength;
 386  
     }
 387  
 
 388  
     /**
 389  
      * Returns the value of the <code>MaxConnections</code> parameter.
 390  
      * 
 391  
      * @return the value of the <code>MaxConnections</code> parameter
 392  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 393  
      */
 394  
     public int getMaxConnections () throws SettingsException {
 395  0
         checkIfNull(maxConnections);
 396  0
         return maxConnections;
 397  
     }
 398  
 
 399  
     /**
 400  
      * Returns the value of the <code>MaxOutstandingR2T</code> parameter.
 401  
      * 
 402  
      * @return the value of the <code>MaxOutstandingR2T</code> parameter
 403  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 404  
      */
 405  
     public int getMaxOutstandingR2T () throws SettingsException {
 406  0
         checkIfNull(maxOutstandingR2T);
 407  0
         return maxOutstandingR2T;
 408  
     }
 409  
 
 410  
     /**
 411  
      * Returns the value of the <code>SessionType</code> parameter.
 412  
      * 
 413  
      * @return the value of the <code>SessionType</code> parameter
 414  
      * @throws SettingsException if the parameter has not been declared or negotiated and there is no default value
 415  
      */
 416  
     public String getSessionType () throws SettingsException {
 417  0
         checkIfNull(maxOutstandingR2T);
 418  0
         return sessionType;
 419  
     }
 420  
 
 421  
     public String getTargetName () throws SettingsException {
 422  0
         return targetName;
 423  
     }
 424  
 }