コード例 #1
0
 private static long getLifetime(SrmPrepareToPutRequest request, long max)
     throws SRMInvalidRequestException {
   long lifetimeInSeconds = 0;
   if (request.getDesiredTotalRequestTime() != null) {
     long reqLifetime = (long) request.getDesiredTotalRequestTime().intValue();
     if (reqLifetime < 0) {
       /* [ SRM 2.2, 5.5.2 ]
        * q)    If input parameter desiredTotalRequestTime is 0 (zero), each file
        *       request must be tried at least once. Negative value must be invalid.
        */
       throw new SRMInvalidRequestException("Negative desiredTotalRequestTime is invalid.");
     }
     lifetimeInSeconds = reqLifetime;
   }
   if (lifetimeInSeconds <= 0) {
     // Revisit: Behaviour doesn't match the SRM spec
     return max;
   }
   long lifetime = TimeUnit.SECONDS.toMillis(lifetimeInSeconds);
   return lifetime > max ? max : lifetime;
 }