Apache Mesos
gc.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __SLAVE_GC_HPP__
18 #define __SLAVE_GC_HPP__
19 
20 #include <string>
21 #include <vector>
22 
23 #include <process/future.hpp>
24 
25 #include <stout/duration.hpp>
26 #include <stout/nothing.hpp>
27 
28 namespace mesos {
29 namespace internal {
30 namespace slave {
31 
32 // Forward declarations.
33 class GarbageCollectorProcess;
34 
35 // Provides an abstraction for removing files and directories after
36 // some point at which they are no longer considered necessary to keep
37 // around. The intent with this abstraction is to also easily enable
38 // implementations that may actually copy files and directories to
39 // "more" permanent storage (or provide any other hooks that might be
40 // useful, e.g., emailing users some time before their files are
41 // scheduled for removal).
43 {
44 public:
45  explicit GarbageCollector(const std::string& workDir);
46  virtual ~GarbageCollector();
47 
48  // Schedules the specified path for removal after the specified
49  // duration of time has elapsed. If the path is already scheduled,
50  // this will reschedule the removal operation, and induce a discard
51  // on the previous future.
52  // The future will become ready when the path has been removed.
53  // The future will fail if the path did not exist, or on error.
54  // The future will be discarded if the path was unscheduled, or
55  // was rescheduled.
56  // Note that you currently cannot discard a returned future, instead
57  // you must call unschedule.
59  const Duration& d,
60  const std::string& path);
61 
62  // Unschedules the specified path for removal.
63  // The future will be true if the path has been unscheduled.
64  // The future will be false if the path is not scheduled for
65  // removal, or the path has already being removed. If path
66  // removal is in progress, the future will be false when the
67  // removal finishes or will fail on unsuccessful removal.
68  virtual process::Future<bool> unschedule(const std::string& path);
69 
70  // Deletes all the directories, whose scheduled garbage collection time
71  // is within the next 'd' duration of time.
72  virtual void prune(const Duration& d);
73 
74 private:
76 };
77 
78 } // namespace slave {
79 } // namespace internal {
80 } // namespace mesos {
81 
82 #endif // __SLAVE_GC_HPP__
Definition: path.hpp:26
Definition: duration.hpp:32
virtual process::Future< bool > unschedule(const std::string &path)
Definition: spec.hpp:30
virtual process::Future< Nothing > schedule(const Duration &d, const std::string &path)
GarbageCollector(const std::string &workDir)
Definition: attributes.hpp:24
Definition: executor.hpp:48
virtual void prune(const Duration &d)