Skip to content

Commit

Permalink
remove deprecated DirectoryPlace constructors (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-mlb authored Feb 21, 2024
1 parent 8c9de6a commit 1869e7a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 65 deletions.
18 changes: 18 additions & 0 deletions src/main/java/emissary/admin/PlaceStarter.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import emissary.core.NamespaceException;
import emissary.directory.DirectoryEntry;
import emissary.directory.DirectoryPlace;
import emissary.directory.EmissaryNode;
import emissary.directory.IDirectoryPlace;
import emissary.directory.KeyManipulator;
import emissary.place.IServiceProviderPlace;
Expand Down Expand Up @@ -75,6 +76,23 @@ public static IServiceProviderPlace createPlace(final String theLocation, final
return createPlace(theLocation, constructorArgs, theClassStr);
}

/**
* Create a place using Stream based config
*
* @param theLocation key for the new place
* @param theConfigStream stream configuration for the place
* @param theClassStr string name of the class to instantiate
* @param directory the string directory name to register in
* @param node the emissary node
* @return the place that was found or created, or null if it can't be done
*/
public static IServiceProviderPlace createPlace(final String theLocation, final InputStream theConfigStream, final String theClassStr,
final String directory, final EmissaryNode node) {
// generate constructor args
final Object[] constructorArgs = {theConfigStream, directory, theLocation, node};
return createPlace(theLocation, constructorArgs, theClassStr);
}

/**
* Create a place using generic Object[] constructor args for maximum flexibility for finding any existing constructor.
* Will check to see if the place already exists first and return the existing instance from the Namespace if it does.
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/emissary/admin/Startup.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,15 @@ protected boolean localDirectorySetup(final Map<String, String> localDirectories

final long start = System.currentTimeMillis();
final Map<String, String> dirStarts = new HashMap<>();
EmissaryNode emissaryNode = new EmissaryNode();
for (final String thePlaceLocation : hostParameters) {

final String host = placeHost(thePlaceLocation);

if (KeyManipulator.isLocalTo(thePlaceLocation, "http://" + this.node.getNodeName() + ":" + this.node.getNodePort() + "/StartupEngine")) {
logger.info("Doing local startup for directory {} ", thePlaceLocation);
final String thePlaceClassStr = PlaceStarter.getClassString(thePlaceLocation);
final IServiceProviderPlace p = PlaceStarter.createPlace(thePlaceLocation, null, thePlaceClassStr, null);
final IServiceProviderPlace p = PlaceStarter.createPlace(thePlaceLocation, null, thePlaceClassStr, null, emissaryNode);
if (p != null) {
dirStarts.put(host, thePlaceLocation);
localDirectoriesArg.put(host, p.toString());
Expand Down
64 changes: 0 additions & 64 deletions src/main/java/emissary/directory/DirectoryPlace.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,6 @@ public class DirectoryPlace extends ServiceProviderPlace implements IRemoteDirec
*/
protected long zoneSlopWindowMillis = 30000; // 30 sec

/**
* Create a new empty directory using this location and no parent
*
* @param placeLoc string key to register this directory
* @throws IOException when configuration fails
* @deprecated use {@link #DirectoryPlace(String, EmissaryNode)}
*/
@Deprecated
// need to pass in EmissaryNode
public DirectoryPlace(final String placeLoc) throws IOException {
super(placeLoc);
this.emissaryNode = new EmissaryNode();
setupDirectory();
}

/**
* Create a new empty directory using this location and no parent
*
Expand All @@ -112,55 +97,6 @@ public DirectoryPlace(final String placeLoc, EmissaryNode node) throws IOExcepti
setupDirectory();
}

/**
* Create a new empty directory as specified by the config info no parent.
*
* @param configInfo our config file to read
* @param placeLoc string key to register this directory
* @throws IOException when configuration fails
* @deprecated use {@link #DirectoryPlace(String, String, EmissaryNode)}
*/
@Deprecated
// need to pass in EmissaryNode
public DirectoryPlace(final String configInfo, final String placeLoc) throws IOException {
this(configInfo, null, placeLoc);
}

/**
* Create a new child directory as specified by the config info with a parent for relaying through.
*
* @param configInfo our config file to read
* @param parentDir string key of the parent directory
* @param placeLoc string key to register this directory
* @throws IOException when configuration fails
* @deprecated use {@link #DirectoryPlace(String, String, EmissaryNode)}
*/
@Deprecated
// need to pass in EmissaryNode
public DirectoryPlace(final String configInfo, final String parentDir, final String placeLoc) throws IOException {
super(configInfo, parentDir, placeLoc);
this.emissaryNode = new EmissaryNode();
setupDirectory();
}

/**
* Create a new directory as specified by the config info with a parent for relaying through.
*
* @param configStream config info
* @param parentDir the parent directory or null if none
* @param placeLoc key for this place
* @throws IOException when configuration fails
* @deprecated use {@link #DirectoryPlace(InputStream, String, String, EmissaryNode)}
*/
@Deprecated
// need to pass in EmissaryNode
// is actually/accidentally the one used by Startup/PlaceStarter.createPlace and probably shouldn't be?
public DirectoryPlace(final InputStream configStream, final String parentDir, final String placeLoc) throws IOException {
super(configStream, parentDir, placeLoc);
this.emissaryNode = new EmissaryNode();
setupDirectory();
}

/**
* Create a new directory as specified by the config info with a parent for relaying through.
*
Expand Down

0 comments on commit 1869e7a

Please sign in to comment.