Skip to content

Commit

Permalink
Merge pull request #57 from italiangrid/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
enricovianello committed Mar 16, 2015
2 parents ab11041 + eec4246 commit 9ea0ba4
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 109 deletions.
3 changes: 2 additions & 1 deletion etc/db/storm_mysql_tbl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS db_version (
description VARCHAR(100));

DELETE FROM storm_db.db_version;
INSERT INTO storm_db.db_version (major,minor,revision,description) VALUES (1,7,1,'27 Jan 2015');
INSERT INTO storm_db.db_version (major,minor,revision,description) VALUES (1,7,2,'10 Mar 2015');

CREATE TABLE IF NOT EXISTS request_queue (
ID int not null auto_increment,
Expand Down Expand Up @@ -278,6 +278,7 @@ ALTER TABLE status_Put
add constraint FK_status_Put_3223 foreign key (request_PutID) references request_Put (ID) ON DELETE CASCADE;

CREATE INDEX statusCode_index on status_Put (statusCode);
CREATE INDEX statusCodeGet_index on status_Get (statusCode);
CREATE INDEX transferURL_index ON status_Put (transferURL(255));

ALTER TABLE request_BoL
Expand Down
5 changes: 5 additions & 0 deletions etc/db/storm_mysql_update_from_1.7.1_to_1.7.2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DELETE FROM storm_db.db_version;
INSERT INTO storm_db.db_version (major,minor,revision,description) VALUES (1,7,2,'10 Mar 2015');

CREATE INDEX statusCodeGet_index on storm_db.status_Get (statusCode);

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<name>StoRM Backend server</name>
<groupId>org.italiangrid.storm</groupId>
<artifactId>storm-backend-server</artifactId>
<version>1.11.7</version>
<version>1.11.8</version>

<properties>

Expand Down
199 changes: 100 additions & 99 deletions src/main/assemblies/assembly.xml
Original file line number Diff line number Diff line change
@@ -1,103 +1,104 @@
<?xml version="1.0"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

<id>storm-backend</id>

<includeBaseDirectory>false</includeBaseDirectory>

<formats>
<format>tar.gz</format>
</formats>

<!-- include all project dependencies and the project artifact -->
<dependencySets>
<dependencySet>
<!-- need to exclude this old xerces version that would otherwise be brough
in as a commons-dbcp dendendency. Though the compiler seems to resolve the
conflict fine, the assembly plugin put it in the package -->
<excludes>
<exclude>xerces:xerces</exclude>
<exclude>org.italiangrid:storm-native-interface</exclude>
</excludes>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>usr/share/java/storm-backend-server</outputDirectory>
</dependencySet>
</dependencySets>

<fileSets>

<!-- include a few file in etc -->
<fileSet>
<directory>etc</directory>
<includes>
<include>lcmaps.db</include>
<include>logging.xml</include>
<include>namespace-1.5.0.xsd</include>
<include>namespace.xml</include>
<include>path-authz.db</include>
<include>storm.properties.template</include>
<include>used-space.ini.template</include>
<include>welcome.txt</include>
</includes>
<outputDirectory>etc/storm/backend-server</outputDirectory>
</fileSet>

<!-- include a few file in etc/db -->
<fileSet>
<directory>etc/db</directory>
<includes>
<include>storm_be_ISAM_mysql_update_from_1.0.0_to_1.1.0.sql</include>
<include>storm_mysql_grant.sql</include>
<include>storm_mysql_tbl.sql</include>
<include>storm_mysql_update_from_1.7.0_to_1.7.1.sql</include>
</includes>
<outputDirectory>etc/storm/backend-server/db</outputDirectory>
</fileSet>

<!-- an empty fileset to create an empty log directory -->
<fileSet>
<directory>src</directory>
<outputDirectory>var/log/storm</outputDirectory>
<excludes>
<exclude>**/*</exclude>
</excludes>
<directoryMode>0755</directoryMode>
</fileSet>

</fileSets>

<files>

<file>
<source>etc/db/storm_database_config.sh</source>
<outputDirectory>etc/storm/backend-server/db</outputDirectory>
<fileMode>0755</fileMode>
</file>

<file>
<source>target/${artifactId}.jar</source>
<outputDirectory>usr/share/java/storm-backend-server</outputDirectory>
</file>

<file>
<source>etc/init.d/storm-backend-server</source>
<outputDirectory>etc/init.d</outputDirectory>
<fileMode>0755</fileMode>
</file>

<file>
<source>etc/logrotate.d/storm-backend-server</source>
<outputDirectory>etc/logrotate.d</outputDirectory>
</file>

<file>
<source>etc/sysconfig/storm-backend-server</source>
<outputDirectory>etc/sysconfig</outputDirectory>
</file>

</files>
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

<id>storm-backend</id>

<includeBaseDirectory>false</includeBaseDirectory>

<formats>
<format>tar.gz</format>
</formats>

<!-- include all project dependencies and the project artifact -->
<dependencySets>
<dependencySet>
<!-- need to exclude this old xerces version that would otherwise be brough
in as a commons-dbcp dendendency. Though the compiler seems to resolve the
conflict fine, the assembly plugin put it in the package -->
<excludes>
<exclude>xerces:xerces</exclude>
<exclude>org.italiangrid:storm-native-interface</exclude>
</excludes>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>usr/share/java/storm-backend-server</outputDirectory>
</dependencySet>
</dependencySets>

<fileSets>

<!-- include a few file in etc -->
<fileSet>
<directory>etc</directory>
<includes>
<include>lcmaps.db</include>
<include>logging.xml</include>
<include>namespace-1.5.0.xsd</include>
<include>namespace.xml</include>
<include>path-authz.db</include>
<include>storm.properties.template</include>
<include>used-space.ini.template</include>
<include>welcome.txt</include>
</includes>
<outputDirectory>etc/storm/backend-server</outputDirectory>
</fileSet>

<!-- include a few file in etc/db -->
<fileSet>
<directory>etc/db</directory>
<includes>
<include>storm_be_ISAM_mysql_update_from_1.0.0_to_1.1.0.sql</include>
<include>storm_mysql_grant.sql</include>
<include>storm_mysql_tbl.sql</include>
<include>storm_mysql_update_from_1.7.0_to_1.7.1.sql</include>
<include>storm_mysql_update_from_1.7.1_to_1.7.2.sql</include>
</includes>
<outputDirectory>etc/storm/backend-server/db</outputDirectory>
</fileSet>

<!-- an empty fileset to create an empty log directory -->
<fileSet>
<directory>src</directory>
<outputDirectory>var/log/storm</outputDirectory>
<excludes>
<exclude>**/*</exclude>
</excludes>
<directoryMode>0755</directoryMode>
</fileSet>

</fileSets>

<files>

<file>
<source>etc/db/storm_database_config.sh</source>
<outputDirectory>etc/storm/backend-server/db</outputDirectory>
<fileMode>0755</fileMode>
</file>

<file>
<source>target/${artifactId}.jar</source>
<outputDirectory>usr/share/java/storm-backend-server</outputDirectory>
</file>

<file>
<source>etc/init.d/storm-backend-server</source>
<outputDirectory>etc/init.d</outputDirectory>
<fileMode>0755</fileMode>
</file>

<file>
<source>etc/logrotate.d/storm-backend-server</source>
<outputDirectory>etc/logrotate.d</outputDirectory>
</file>

<file>
<source>etc/sysconfig/storm-backend-server</source>
<outputDirectory>etc/sysconfig</outputDirectory>
</file>

</files>

</assembly>
38 changes: 31 additions & 7 deletions src/main/java/it/grid/storm/catalogs/surl/SURLStatusDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public boolean abortActivePtPsForSURL(GridUserInterface user, TSURL surl,
stat = con.prepareStatement(query);
stat.setString(1, explanation);
stat.setString(2, surl.getSURLString());
stat.setInt(3, surl.uniqueId());
stat.setInt(3, surl.uniqueId());

if (user != null) {
stat.setString(4, user.getDn());
}
Expand All @@ -120,7 +120,7 @@ public boolean abortActivePtPsForSURL(GridUserInterface user, TSURL surl,
surl, updateCount);

return (updateCount != 0);

} catch (SQLException e) {
String msg = String.format("abortActivePtPsForSURL: SQL error: %s",
e.getMessage());
Expand Down Expand Up @@ -493,6 +493,22 @@ public void markSURLsReadyForRead(TRequestToken token, List<TSURL> surls) {

}

private String quoteSURLUniqueIDs(List<TSURL> surls) {

StringBuilder sb = new StringBuilder();

for (TSURL s : surls) {
if (sb.length() > 0) {
sb.append(",");
}

sb.append(s.uniqueId());
}

return sb.toString();

}

private String quoteSURLList(List<TSURL> surls) {

StringBuilder sb = new StringBuilder();
Expand Down Expand Up @@ -523,10 +539,11 @@ public void releaseSURL(TSURL surl) {
+ "ON sg.request_GetID=rg.ID AND rg.request_queueID=rq.ID "
+ "SET sg.statusCode=21"
+ "WHERE (sg.statusCode=22 OR sg.statusCode=0) "
+ "AND rg.sourceSURL = ?";
+ "AND rg.sourceSURL = ? and rg.sourceSURL_uniqueID = ?";

stat = con.prepareStatement(query);
stat.setString(1, surl.getSURLString());
stat.setInt(2, surl.uniqueId());

stat.executeUpdate();
} catch (SQLException e) {
Expand Down Expand Up @@ -556,6 +573,7 @@ public void releaseSURLs(GridUserInterface user, List<TSURL> surls) {
+ "ON sg.request_GetID=rg.ID AND rg.request_queueID=rq.ID "
+ "SET sg.statusCode=21 "
+ "WHERE (sg.statusCode=22 OR sg.statusCode=0) "
+ "AND rg.sourceSURL_uniqueID IN (" + quoteSURLUniqueIDs(surls) + ") "
+ "AND rg.sourceSURL IN (" + quoteSURLList(surls) + ") "
+ "AND rq.client_dn = ?";

Expand Down Expand Up @@ -592,6 +610,7 @@ public void releaseSURLs(List<TSURL> surls) {
+ "ON sg.request_GetID=rg.ID AND rg.request_queueID=rq.ID "
+ "SET sg.statusCode=21 "
+ "WHERE (sg.statusCode=22 OR sg.statusCode=0) "
+ "AND rg.sourceSURL_uniqueID IN (" + quoteSURLUniqueIDs(surls) + ") "
+ "AND rg.sourceSURL IN (" + quoteSURLList(surls) + ")";

stat = con.prepareStatement(query);
Expand Down Expand Up @@ -624,6 +643,7 @@ public void releaseSURLs(TRequestToken token, List<TSURL> surls) {
+ "ON sg.request_GetID=rg.ID AND rg.request_queueID=rq.ID "
+ "SET sg.statusCode=21 "
+ "WHERE (sg.statusCode=22 OR sg.statusCode=0) "
+ "AND rg.sourceSURL_uniqueID IN (" + quoteSURLUniqueIDs(surls) + ") "
+ "AND rg.sourceSURL IN (" + quoteSURLList(surls) + ") "
+ "AND rq.r_token = ?";

Expand Down Expand Up @@ -670,10 +690,12 @@ public boolean surlHasOngoingPtGs(TSURL surl) {
String query = "SELECT rq.ID, rg.ID, sg.statusCode "
+ "FROM request_queue rq JOIN (request_Get rg, status_Get sg) "
+ "ON (rg.request_queueID = rq.ID AND sg.request_GetID = rg.ID) "
+ "WHERE ( rg.sourceSURL = ? and sg.statusCode = 22)";
+ "WHERE ( rg.sourceSURL = ? and rg.sourceSURL_uniqueID = ? "
+ "and sg.statusCode = 22 )";

stat = con.prepareStatement(query);
stat.setString(1, surl.getSURLString());
stat.setInt(2, surl.uniqueId());

rs = stat.executeQuery();
return rs.next();
Expand Down Expand Up @@ -705,17 +727,19 @@ public boolean surlHasOngoingPtPs(TSURL surl, TRequestToken ptpRequestToken) {
String query = "SELECT rq.ID, rp.ID, sp.statusCode "
+ "FROM request_queue rq JOIN (request_Put rp, status_Put sp) "
+ "ON (rp.request_queueID=rq.ID AND sp.request_PutID=rp.ID) "
+ "WHERE ( rp.targetSURL = ? and sp.statusCode=24 )";
+ "WHERE ( rp.targetSURL = ? and rp.targetSURL_uniqueID = ? "
+ "and sp.statusCode=24 )";

if (ptpRequestToken != null) {
query += " AND rq.r_token != ?";
}

stat = con.prepareStatement(query);
stat.setString(1, surl.getSURLString());
stat.setInt(2, surl.uniqueId());

if (ptpRequestToken != null) {
stat.setString(2, ptpRequestToken.getValue());
stat.setString(3, ptpRequestToken.getValue());
}

rs = stat.executeQuery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public boolean abortAllPutRequestsForSURL(GridUserInterface user, TSURL surl,
String explanation) {

final SURLStatusDAO dao = new SURLStatusDAO();
return dao.abortActivePtGsForSURL(user, surl, explanation);
return dao.abortActivePtPsForSURL(user, surl, explanation);

}

Expand Down

0 comments on commit 9ea0ba4

Please sign in to comment.