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 * https://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.api.ldap.extras.extended.gracefulShutdown; 021 022 023import org.apache.directory.api.ldap.model.message.OpaqueExtendedRequest; 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 OpaqueExtendedRequest implements GracefulShutdownRequest 036{ 037 /** Offline time after disconnection */ 038 private int timeOffline; 039 040 /** Delay before disconnection */ 041 private int delay; 042 043 044 /** 045 * Instantiates a new graceful shutdown request. 046 * 047 * @param messageId the message id 048 */ 049 public GracefulShutdownRequestImpl( int messageId ) 050 { 051 this( messageId, UNDETERMINED, NOW ); 052 } 053 054 055 /** 056 * Instantiates a new graceful shutdown request. 057 */ 058 public GracefulShutdownRequestImpl() 059 { 060 setRequestName( EXTENSION_OID ); 061 } 062 063 064 /** 065 * Instantiates a new graceful shutdown request. 066 * 067 * @param messageId the message id 068 * @param timeOffline the offline time after disconnection, in minutes 069 * @param delay the delay before disconnection, in seconds 070 */ 071 public GracefulShutdownRequestImpl( int messageId, int timeOffline, int delay ) 072 { 073 super( messageId ); 074 setRequestName( EXTENSION_OID ); 075 this.timeOffline = timeOffline; 076 this.delay = delay; 077 } 078 079 080 // ----------------------------------------------------------------------- 081 // Parameters of the Extended Request Payload 082 // ----------------------------------------------------------------------- 083 084 /** 085 * {@inheritDoc} 086 */ 087 @Override 088 public int getDelay() 089 { 090 return delay; 091 } 092 093 094 /** 095 * {@inheritDoc} 096 */ 097 @Override 098 public void setDelay( int delay ) 099 { 100 this.delay = delay; 101 } 102 103 104 /** 105 * {@inheritDoc} 106 */ 107 @Override 108 public int getTimeOffline() 109 { 110 return timeOffline; 111 } 112 113 114 /** 115 * {@inheritDoc} 116 */ 117 @Override 118 public void setTimeOffline( int timeOffline ) 119 { 120 this.timeOffline = timeOffline; 121 } 122 123 124 /** 125 * {@inheritDoc} 126 */ 127 @Override 128 public GracefulShutdownResponse getResultResponse() 129 { 130 if ( getResponse() == null ) 131 { 132 setResponse( new GracefulShutdownResponseImpl() ); 133 } 134 135 return ( GracefulShutdownResponse ) getResponse(); 136 } 137}