| 
									
										
										
										
											2016-08-18 02:36:33 +08:00
										 |  |  | /* | 
					
						
							|  |  |  |  * Minio Cloud Storage, (C) 2016 Minio, Inc. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  |  * you may not use this file except in compliance with the License. | 
					
						
							|  |  |  |  * You may obtain a copy of the License at | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *     http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  |  * See the License for the specific language governing permissions and | 
					
						
							|  |  |  |  * limitations under the License. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-19 07:23:42 +08:00
										 |  |  | package cmd | 
					
						
							| 
									
										
										
										
											2016-08-18 02:36:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // HealListArgs - argument for ListObjects RPC.
 | 
					
						
							|  |  |  | type HealListArgs struct { | 
					
						
							|  |  |  | 	Bucket    string | 
					
						
							|  |  |  | 	Prefix    string | 
					
						
							|  |  |  | 	Marker    string | 
					
						
							|  |  |  | 	Delimiter string | 
					
						
							|  |  |  | 	MaxKeys   int | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // HealListReply - reply by ListObjects RPC.
 | 
					
						
							|  |  |  | type HealListReply struct { | 
					
						
							|  |  |  | 	IsTruncated bool | 
					
						
							|  |  |  | 	NextMarker  string | 
					
						
							|  |  |  | 	Objects     []string | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-22 03:06:53 +08:00
										 |  |  | // ListObjects - list all objects that needs healing.
 | 
					
						
							|  |  |  | func (c *controllerAPIHandlers) ListObjectsHeal(arg *HealListArgs, reply *HealListReply) error { | 
					
						
							| 
									
										
										
										
											2016-08-19 05:50:50 +08:00
										 |  |  | 	objAPI := c.ObjectAPI() | 
					
						
							| 
									
										
										
										
											2016-08-22 03:06:53 +08:00
										 |  |  | 	if objAPI == nil { | 
					
						
							|  |  |  | 		return errInvalidArgument | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	info, err := objAPI.ListObjectsHeal(arg.Bucket, arg.Prefix, arg.Marker, arg.Delimiter, arg.MaxKeys) | 
					
						
							| 
									
										
										
										
											2016-08-18 02:36:33 +08:00
										 |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	reply.IsTruncated = info.IsTruncated | 
					
						
							|  |  |  | 	reply.NextMarker = info.NextMarker | 
					
						
							|  |  |  | 	for _, obj := range info.Objects { | 
					
						
							|  |  |  | 		reply.Objects = append(reply.Objects, obj.Name) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // HealObjectArgs - argument for HealObject RPC.
 | 
					
						
							|  |  |  | type HealObjectArgs struct { | 
					
						
							|  |  |  | 	Bucket string | 
					
						
							|  |  |  | 	Object string | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // HealObjectReply - reply by HealObject RPC.
 | 
					
						
							|  |  |  | type HealObjectReply struct{} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // HealObject - heal the object.
 | 
					
						
							| 
									
										
										
										
											2016-08-22 03:06:53 +08:00
										 |  |  | func (c *controllerAPIHandlers) HealObject(arg *HealObjectArgs, reply *HealObjectReply) error { | 
					
						
							| 
									
										
										
										
											2016-08-19 05:50:50 +08:00
										 |  |  | 	objAPI := c.ObjectAPI() | 
					
						
							| 
									
										
										
										
											2016-08-22 03:06:53 +08:00
										 |  |  | 	if objAPI == nil { | 
					
						
							|  |  |  | 		return errInvalidArgument | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return objAPI.HealObject(arg.Bucket, arg.Object) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // ShutdownArgs - argument for Shutdown RPC.
 | 
					
						
							|  |  |  | type ShutdownArgs struct { | 
					
						
							|  |  |  | 	Reboot bool | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // ShutdownReply - reply by Shutdown RPC.
 | 
					
						
							|  |  |  | type ShutdownReply struct{} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Shutdown - Shutdown the server.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (c *controllerAPIHandlers) Shutdown(arg *ShutdownArgs, reply *ShutdownReply) error { | 
					
						
							|  |  |  | 	if arg.Reboot { | 
					
						
							|  |  |  | 		globalShutdownSignalCh <- shutdownRestart | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		globalShutdownSignalCh <- shutdownHalt | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return nil | 
					
						
							| 
									
										
										
										
											2016-08-18 02:36:33 +08:00
										 |  |  | } |