001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.shared.ldap.extras.extended; 021 022 023import org.apache.directory.shared.ldap.model.message.AbstractExtendedRequest; 024 025 026/** 027 * An extended operation requesting the server to shutdown it's LDAP service 028 * port while allowing established clients to complete or abandon operations 029 * already in progress. More information about this extended request is 030 * available here: <a href="http://docs.safehaus.org:8080/x/GR">LDAP Extensions 031 * for Graceful Shutdown</a>. 032 * 033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 034 */ 035public class GracefulShutdownRequestImpl extends AbstractExtendedRequest<GracefulShutdownResponse> implements GracefulShutdownRequest 036{ 037 /** The serialVersionUID. */ 038 private static final long serialVersionUID = -4682291068700593492L; 039 040 private GracefulShutdownResponse response; 041 042 /** Offline time after disconnection */ 043 private int timeOffline; 044 045 /** Delay before disconnection */ 046 private int delay; 047 048 049 /** 050 * Instantiates a new graceful shutdown request. 051 * 052 * @param messageId the message id 053 */ 054 public GracefulShutdownRequestImpl( int messageId ) 055 { 056 this( messageId, UNDETERMINED, NOW ); 057 } 058 059 060 /** 061 * Instantiates a new graceful shutdown request. 062 * 063 * @param messageId the message id 064 */ 065 public GracefulShutdownRequestImpl() 066 { 067 setRequestName( EXTENSION_OID ); 068 } 069 070 071 /** 072 * Instantiates a new graceful shutdown request. 073 * 074 * @param messageId the message id 075 * @param timeOffline the offline time after disconnection, in minutes 076 * @param delay the delay before disconnection, in seconds 077 */ 078 public GracefulShutdownRequestImpl( int messageId, int timeOffline, int delay ) 079 { 080 super( messageId ); 081 setRequestName( EXTENSION_OID ); 082 this.timeOffline = timeOffline; 083 this.delay = delay; 084 } 085 086 087 // ----------------------------------------------------------------------- 088 // Parameters of the Extended Request Payload 089 // ----------------------------------------------------------------------- 090 091 092 /** 093 * {@inheritDoc} 094 */ 095 public int getDelay() 096 { 097 return delay; 098 } 099 100 101 /** 102 * {@inheritDoc} 103 */ 104 public void setDelay( int delay ) 105 { 106 this.delay = delay; 107 } 108 109 110 /** 111 * {@inheritDoc} 112 */ 113 public int getTimeOffline() 114 { 115 return timeOffline; 116 } 117 118 119 /** 120 * {@inheritDoc} 121 */ 122 public void setTimeOffline( int timeOffline ) 123 { 124 this.timeOffline = timeOffline; 125 } 126 127 128 @Override 129 public GracefulShutdownResponse getResultResponse() 130 { 131 if ( response == null ) 132 { 133 response = new GracefulShutdownResponseImpl(); 134 } 135 136 return response; 137 } 138}