Skip to content

Commit

Permalink
Tracker #164702206 -
Browse files Browse the repository at this point in the history
[Inv Versions] Add NodeIO table  support for bucket identification
Support for NodeIO tables in versions processing
Support of standard form of localVolume in storage can-info.txt
Update filenode method to use current storageBase
  • Loading branch information
replic committed Mar 21, 2019
1 parent 650bb5c commit a095512
Show file tree
Hide file tree
Showing 7 changed files with 699 additions and 9 deletions.
6 changes: 6 additions & 0 deletions inv-src/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@
<artifactId>mrt-zoopub-src</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.cdlib.mrt</groupId>
<artifactId>mrt-confs3</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

<!--
<dependency>
Expand Down
27 changes: 23 additions & 4 deletions inv-src/src/main/java/org/cdlib/mrt/inv/action/SaveNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,38 @@ public class SaveNode
protected InvNode canInvNode = null;
protected int nodeNumber = 0;
protected DBAdd dbAdd = null;
protected String storageBase = null;

public static SaveNode getSaveNode(
int nodeNumber,
Connection connection,
LoggerInf logger)
throws TException
{
return new SaveNode(nodeNumber, connection, logger);
return new SaveNode(nodeNumber, connection, null, logger);
}

public static SaveNode getSaveNode(
int nodeNumber,
Connection connection,
String storageBase,
LoggerInf logger)
throws TException
{
return new SaveNode(nodeNumber, connection, storageBase, logger);
}

protected SaveNode(
int nodeNumber,
Connection connection,
String storageBase,
LoggerInf logger)
throws TException
{
super(connection, logger);
try {
this.nodeNumber = nodeNumber;
this.storageBase = storageBase;
dbAdd = new DBAdd(connection, logger);
validate();

Expand Down Expand Up @@ -122,8 +135,14 @@ protected void extractNode()
throw new TException.INVALID_OR_MISSING_PARM(MESSAGE + "Existing db invNode required for this process");
}

System.out.println(PropertiesUtil.dumpProperties("sourceInvNode", sourceInvNode.retrieveProp()));
String baseUrl = sourceInvNode.getBaseURL();
String baseUrl = storageBase;
if (baseUrl == null) {
baseUrl = sourceInvNode.getBaseURL();
}
System.out.println("***SaveNode:"
+ " - baseUrl=" + baseUrl
+ " - nodeNumber=" + nodeNumber
);
StoreState storeState = StoreState.getStoreState(baseUrl, nodeNumber, logger);
canInvNode = new InvNode(logger);
canInvNode.setState(storeState);
Expand Down Expand Up @@ -174,6 +193,6 @@ public Properties getCanProp()
}
return canInvNode.retrieveProp();
}

}

35 changes: 33 additions & 2 deletions inv-src/src/main/java/org/cdlib/mrt/inv/action/Versions.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
*******************************************************************************/
package org.cdlib.mrt.inv.action;

import org.cdlib.mrt.inv.utility.NodeIOInv;
import java.io.File;
import java.sql.Connection;
import java.util.List;
import java.util.Properties;
import org.cdlib.mrt.core.Identifier;
import static org.cdlib.mrt.inv.utility.NodeIOInv.getCloudNode;
import org.cdlib.mrt.inv.content.InvFile;
import org.cdlib.mrt.inv.content.InvNode;
import org.cdlib.mrt.inv.content.InvObject;
Expand Down Expand Up @@ -116,7 +118,8 @@ protected void setStateStuff()
{
Properties versionsProp = InvDBUtil.getVersionsStuff(objectID, connection, logger);
String nodeS = versionsProp.getProperty("number");
String bucket = versionsProp.getProperty("logical_volume");
long node = Long.parseLong(nodeS);
String bucket = getContainer(versionsProp);
String ext = versionsProp.getProperty("md5_3");
int pos = bucket.lastIndexOf("__");
if ((pos >= 0) && (bucket.length() - pos == 2)) {
Expand All @@ -128,12 +131,40 @@ protected void setStateStuff()
containerProp = bucket.substring(posProp+1);
bucket = bucket.substring(0, posProp);
}
long node = Long.parseLong(nodeS);
state.setContainer(bucket);
state.setBucketProperty(containerProp);
state.setNode(node);
}

private String getContainer(Properties versionsProp)
throws TException
{
NodeIOInv.AccessNode accessNode = null;
String bucket = versionsProp.getProperty("logical_volume");
if (bucket == null) return null;

if (!bucket.startsWith("nodes")) {
return bucket;
}

String[] parts = bucket.split("\\s*\\|\\s*");
if (parts.length != 2) {
return bucket;
}

//form nodeIOName|nodeNumber
String nodeIOName = parts[0];
String nodeS = parts[1];
int nodeNumber = Integer.parseInt(nodeS);
System.out.println("Versions NodeIOInv: "
+ " - nodeIOName:" + nodeIOName
+ " - nodeNumber:" + nodeNumber
);
accessNode = NodeIOInv.getCloudNode(nodeIOName, nodeNumber, logger);
state.setCloudType(accessNode.serviceType);
return accessNode.container;
}

protected void addVersions()
throws TException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
import org.cdlib.mrt.queue.Item;
import org.cdlib.mrt.utility.TException;
import org.cdlib.mrt.utility.LoggerInf;
import org.cdlib.mrt.utility.PropertiesUtil;
import org.cdlib.mrt.utility.StringUtil;
import org.cdlib.mrt.utility.URLEncoder;

Expand Down Expand Up @@ -191,7 +192,11 @@ public InvSelectState setFileNode(
{
if (DEBUG) System.out.print("setFileNode entered:" + nodeNum);
Connection connection = invServiceProperties.getConnection(false);
SaveNode saveNode = SaveNode.getSaveNode(nodeNum, connection, logger);


SaveNode saveNode = SaveNode.getSaveNode(nodeNum, connection,
invServiceProperties.getStorageBase(),
logger);
saveNode.resetInvNode();
InvSelectState state = new InvSelectState(saveNode.getCanProp());
return state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class VersionsState
protected DateState reportDate = new DateState();
protected String container = null;
protected String bucketProperty = null;
protected String cloudType = null;
protected Long node = null;
protected long currentVersion = 0;
protected ArrayList<Version> versions = new ArrayList<Version>();
Expand Down Expand Up @@ -125,6 +126,14 @@ public String getBucketProperty() {
public void setBucketProperty(String bucketProperty) {
this.bucketProperty = bucketProperty;
}

public String getCloudType() {
return cloudType;
}

public void setCloudType(String cloudType) {
this.cloudType = cloudType;
}

public Set<String> retrieveKeys()
{
Expand Down
11 changes: 9 additions & 2 deletions inv-src/src/main/java/org/cdlib/mrt/inv/test/VersionsTest3.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,24 @@ public static void main(String args[])
try {
String propertyList[] = {
"resources/InvLogger.properties",
"resources/VersionTest.properties",
"resources/Inv.properties"};
tFrame = new TFrame(propertyList, "InvLoad");
Properties invProp = tFrame.getProperties();
LoggerInf logger = new TFileLogger("testFormatter", 10, 10);
db = new DPRFileDB(logger, invProp);
Connection connect = db.getConnection(true);
Identifier objectID = new Identifier("ark:/99999/fk4x92x0c");
Identifier objectID = new Identifier("ark:/99999/fk4x92x0c"); // stg
objectID = new Identifier("ark:/99999/fk42n5jrg"); //dev
objectID = new Identifier("ark:/99999/fk4h71nh38"); //dev 5001
objectID = new Identifier("ark:/99999/testinv9502"); //stg 9502
objectID = new Identifier("ark:/99999/fk4xs60c0j"); //dev 9001
objectID = new Identifier("ark:/99999/fk4h71nh38"); //dev 5001
Long testVersion = null; //3L;
//Identifier objectID = new Identifier("ark:/99999/xxxxx");


test(objectID, null, connect, logger);
test(objectID, testVersion, connect, logger);

} catch(Exception e) {
e.printStackTrace();
Expand Down
Loading

0 comments on commit a095512

Please sign in to comment.