-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
u This is a combination of 2 commits. (#1178)
This PR closes #1176 by fixing the bug reported by * Removing all the remaining query and checkpoint files before launching MIST
- Loading branch information
1 parent
3e14542
commit defc408
Showing
3 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
mist-core/src/main/java/edu/snu/mist/core/master/DefaultSharedStoreManagerImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (C) 2018 Seoul National University | ||
* | ||
* 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. | ||
*/ | ||
package edu.snu.mist.core.master; | ||
|
||
import edu.snu.mist.core.parameters.SharedStorePath; | ||
import org.apache.reef.tang.annotations.Parameter; | ||
|
||
import javax.inject.Inject; | ||
import java.io.File; | ||
|
||
/** | ||
* The default shared store manager implementation class. | ||
*/ | ||
public final class DefaultSharedStoreManagerImpl implements SharedStoreManager { | ||
|
||
/** | ||
* The shared store path. | ||
*/ | ||
private final String sharedStorePath; | ||
|
||
@Inject | ||
private DefaultSharedStoreManagerImpl(@Parameter(SharedStorePath.class) final String sharedStorePath) { | ||
this.sharedStorePath = sharedStorePath; | ||
} | ||
|
||
@Override | ||
public boolean clearSharedStore() { | ||
final File sharedStoreDir = new File(sharedStorePath); | ||
final File[] listing = sharedStoreDir.listFiles(); | ||
if (listing == null) { | ||
throw new RuntimeException("Inavlid shared store directory path. Terminate MIST..."); | ||
} | ||
if (listing.length == 0) { | ||
return true; | ||
} | ||
for (final File file: listing) { | ||
final String fileName = file.getName(); | ||
if (fileName.endsWith(".checkpoint") || fileName.endsWith(".query") || fileName.endsWith(".querylist")) { | ||
// Try to delete the already existing query and checkpoint files... | ||
if (!file.delete()) { | ||
// If we fail to delete the existing files, there should be problems with the shared store... | ||
return false; | ||
} | ||
} | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
mist-core/src/main/java/edu/snu/mist/core/master/SharedStoreManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (C) 2018 Seoul National University | ||
* | ||
* 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. | ||
*/ | ||
package edu.snu.mist.core.master; | ||
|
||
import org.apache.reef.tang.annotations.DefaultImplementation; | ||
|
||
/** | ||
* The interface for master-side. shared store manager | ||
*/ | ||
@DefaultImplementation(DefaultSharedStoreManagerImpl.class) | ||
public interface SharedStoreManager { | ||
|
||
/** | ||
* Clear the legacy query and checkpoint files on the shared store. | ||
*/ | ||
boolean clearSharedStore(); | ||
} |