Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chimera: implement qos policy storage (qos engine 1)
Motivation: Implement the rule engine extension to QoS services. Modification: The first patch adds qos policy management to chimera. A Jdbc layer to storage, querying and retrieval of policy definitions is created. The liquibase change sets also include the addition of two new columns to `t_inodes` which will be used to store the policy and state of individual files. Result: Patch 1 of 8 in the rule engine extension implementation. Target: master Patch: https://rb.dcache.org/r/14064 Acked-by: Tigran
- Loading branch information
Showing
12 changed files
with
975 additions
and
1 deletion.
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
modules/chimera/src/main/java/org/dcache/chimera/qos/JdbcQos.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,118 @@ | ||
/* | ||
COPYRIGHT STATUS: | ||
Dec 1st 2001, Fermi National Accelerator Laboratory (FNAL) documents and | ||
software are sponsored by the U.S. Department of Energy under Contract No. | ||
DE-AC02-76CH03000. Therefore, the U.S. Government retains a world-wide | ||
non-exclusive, royalty-free license to publish or reproduce these documents | ||
and software for U.S. Government purposes. All documents and software | ||
available from this server are protected under the U.S. and Foreign | ||
Copyright Laws, and FNAL reserves all rights. | ||
Distribution of the software available from this server is free of | ||
charge subject to the user following the terms of the Fermitools | ||
Software Legal Information. | ||
Redistribution and/or modification of the software shall be accompanied | ||
by the Fermitools Software Legal Information (including the copyright | ||
notice). | ||
The user is asked to feed back problems, benefits, and/or suggestions | ||
about the software to the Fermilab Software Providers. | ||
Neither the name of Fermilab, the URA, nor the names of the contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
DISCLAIMER OF LIABILITY (BSD): | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FERMILAB, | ||
OR THE URA, OR THE U.S. DEPARTMENT of ENERGY, OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
Liabilities of the Government: | ||
This software is provided by URA, independent from its Prime Contract | ||
with the U.S. Department of Energy. URA is acting independently from | ||
the Government and in its own private capacity and is not acting on | ||
behalf of the U.S. Government, nor as its contractor nor its agent. | ||
Correspondingly, it is understood and agreed that the U.S. Government | ||
has no connection to this software and in no manner whatsoever shall | ||
be liable for nor assume any responsibility or obligation for any claim, | ||
cost, or damages arising out of or resulting from the use of the software | ||
available from this server. | ||
Export Control: | ||
All documents and software available from this server are subject to U.S. | ||
export control laws. Anyone downloading information from this server is | ||
obligated to secure any necessary Government licenses before exporting | ||
documents or software obtained from this server. | ||
*/ | ||
package org.dcache.chimera.qos; | ||
|
||
import java.sql.SQLException; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import javax.sql.DataSource; | ||
import org.dcache.chimera.ChimeraFsException; | ||
import org.dcache.qos.QoSPolicy; | ||
import org.dcache.qos.QoSPolicyStat; | ||
import org.springframework.dao.DataAccessException; | ||
|
||
public class JdbcQos implements QosPolicyHandler { | ||
|
||
private final QosSqlDriver sqlDriver; | ||
|
||
public JdbcQos(DataSource ds) throws SQLException { | ||
sqlDriver = QosSqlDriver.getDriverInstance(ds); | ||
} | ||
|
||
@Override | ||
public void addQosPolicy(QoSPolicy policy) throws ChimeraFsException { | ||
if (!sqlDriver.insertPolicy(policy)) { | ||
throw new ChimeraFsException("could not add qos policy " + policy.getName()); | ||
} | ||
} | ||
|
||
@Override | ||
public Optional<QoSPolicy> getQosPolicy(String name) { | ||
return Optional.ofNullable(sqlDriver.selectPolicy(name)); | ||
} | ||
|
||
@Override | ||
public int removeQosPolicy(String name) throws ChimeraFsException { | ||
try { | ||
int id = sqlDriver.getPolicyId(name); | ||
if (!sqlDriver.deletePolicy(name)) { | ||
throw new ChimeraFsException("failed to delete qos policy " + name); | ||
} | ||
return id; | ||
} catch (DataAccessException e) { | ||
throw new ChimeraFsException("Error getting policy id for + " + name, e); | ||
} | ||
} | ||
|
||
@Override | ||
public List<String> listQoSPolicies() { | ||
return sqlDriver.selectPolicyNames(); | ||
} | ||
|
||
@Override | ||
public List<QoSPolicyStat> getPolicyStatsByPolicyName() { | ||
return sqlDriver.selectCounts(); | ||
} | ||
|
||
@Override | ||
public void invalidate(Integer id) { | ||
sqlDriver.invalidateQosPolicy(id); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
modules/chimera/src/main/java/org/dcache/chimera/qos/PgsqlQosSqlDriver.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,72 @@ | ||
/* | ||
COPYRIGHT STATUS: | ||
Dec 1st 2001, Fermi National Accelerator Laboratory (FNAL) documents and | ||
software are sponsored by the U.S. Department of Energy under Contract No. | ||
DE-AC02-76CH03000. Therefore, the U.S. Government retains a world-wide | ||
non-exclusive, royalty-free license to publish or reproduce these documents | ||
and software for U.S. Government purposes. All documents and software | ||
available from this server are protected under the U.S. and Foreign | ||
Copyright Laws, and FNAL reserves all rights. | ||
Distribution of the software available from this server is free of | ||
charge subject to the user following the terms of the Fermitools | ||
Software Legal Information. | ||
Redistribution and/or modification of the software shall be accompanied | ||
by the Fermitools Software Legal Information (including the copyright | ||
notice). | ||
The user is asked to feed back problems, benefits, and/or suggestions | ||
about the software to the Fermilab Software Providers. | ||
Neither the name of Fermilab, the URA, nor the names of the contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
DISCLAIMER OF LIABILITY (BSD): | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FERMILAB, | ||
OR THE URA, OR THE U.S. DEPARTMENT of ENERGY, OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
Liabilities of the Government: | ||
This software is provided by URA, independent from its Prime Contract | ||
with the U.S. Department of Energy. URA is acting independently from | ||
the Government and in its own private capacity and is not acting on | ||
behalf of the U.S. Government, nor as its contractor nor its agent. | ||
Correspondingly, it is understood and agreed that the U.S. Government | ||
has no connection to this software and in no manner whatsoever shall | ||
be liable for nor assume any responsibility or obligation for any claim, | ||
cost, or damages arising out of or resulting from the use of the software | ||
available from this server. | ||
Export Control: | ||
All documents and software available from this server are subject to U.S. | ||
export control laws. Anyone downloading information from this server is | ||
obligated to secure any necessary Government licenses before exporting | ||
documents or software obtained from this server. | ||
*/ | ||
package org.dcache.chimera.qos; | ||
|
||
import javax.sql.DataSource; | ||
|
||
/** | ||
* For the moment, no necessary optimizations. | ||
*/ | ||
public class PgsqlQosSqlDriver extends QosSqlDriver { | ||
|
||
public PgsqlQosSqlDriver(DataSource dataSource) { | ||
super(dataSource); | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
modules/chimera/src/main/java/org/dcache/chimera/qos/QosPolicyHandler.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,108 @@ | ||
/* | ||
COPYRIGHT STATUS: | ||
Dec 1st 2001, Fermi National Accelerator Laboratory (FNAL) documents and | ||
software are sponsored by the U.S. Department of Energy under Contract No. | ||
DE-AC02-76CH03000. Therefore, the U.S. Government retains a world-wide | ||
non-exclusive, royalty-free license to publish or reproduce these documents | ||
and software for U.S. Government purposes. All documents and software | ||
available from this server are protected under the U.S. and Foreign | ||
Copyright Laws, and FNAL reserves all rights. | ||
Distribution of the software available from this server is free of | ||
charge subject to the user following the terms of the Fermitools | ||
Software Legal Information. | ||
Redistribution and/or modification of the software shall be accompanied | ||
by the Fermitools Software Legal Information (including the copyright | ||
notice). | ||
The user is asked to feed back problems, benefits, and/or suggestions | ||
about the software to the Fermilab Software Providers. | ||
Neither the name of Fermilab, the URA, nor the names of the contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
DISCLAIMER OF LIABILITY (BSD): | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FERMILAB, | ||
OR THE URA, OR THE U.S. DEPARTMENT of ENERGY, OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
Liabilities of the Government: | ||
This software is provided by URA, independent from its Prime Contract | ||
with the U.S. Department of Energy. URA is acting independently from | ||
the Government and in its own private capacity and is not acting on | ||
behalf of the U.S. Government, nor as its contractor nor its agent. | ||
Correspondingly, it is understood and agreed that the U.S. Government | ||
has no connection to this software and in no manner whatsoever shall | ||
be liable for nor assume any responsibility or obligation for any claim, | ||
cost, or damages arising out of or resulting from the use of the software | ||
available from this server. | ||
Export Control: | ||
All documents and software available from this server are subject to U.S. | ||
export control laws. Anyone downloading information from this server is | ||
obligated to secure any necessary Government licenses before exporting | ||
documents or software obtained from this server. | ||
*/ | ||
|
||
package org.dcache.chimera.qos; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import org.dcache.chimera.ChimeraFsException; | ||
import org.dcache.qos.QoSPolicy; | ||
import org.dcache.qos.QoSPolicyStat; | ||
|
||
/** | ||
* Management of QoSPolicy storage and retrieval. | ||
*/ | ||
public interface QosPolicyHandler { | ||
|
||
/** | ||
* Policies cannot be updated or overwritten. | ||
* | ||
* @param policy to add or substitute. | ||
* @throws ChimeraFsException esp. if the policy already exists | ||
*/ | ||
void addQosPolicy(QoSPolicy policy) throws ChimeraFsException; | ||
|
||
/** | ||
* @param name must be unique to the dCache instance. | ||
* @return an optional of the corresponding policy. | ||
*/ | ||
Optional<QoSPolicy> getQosPolicy(String name) throws ChimeraFsException; | ||
|
||
/** | ||
* @param name must be unique to the dCache instance. | ||
* @return the id of the policy that has been removed | ||
*/ | ||
int removeQosPolicy(String name) throws ChimeraFsException; | ||
|
||
/** | ||
* @return list of all registered QoS policy names. | ||
*/ | ||
List<String> listQoSPolicies() throws ChimeraFsException; | ||
|
||
/** | ||
* @return list of state counts by policy name. | ||
*/ | ||
List<QoSPolicyStat> getPolicyStatsByPolicyName(); | ||
|
||
/** | ||
* @param id of the invalid QoS policy. | ||
*/ | ||
void invalidate(Integer id); | ||
} |
Oops, something went wrong.