Skip to content

Commit

Permalink
spacemanager: Remove obsolete features
Browse files Browse the repository at this point in the history
Due to the introduction of unique write TURLs, several space manager features
are no longer needed. This patch removes those featurs.

The removed features are all a result of no longer needing the ALLOCATED state
of a file reservation. Thus there is no need to bind file reservations to a
path, no need to track deleted paths, and no need to track lifetime of a file
reservation (the lifetime is now that of the PNFS ID). As a consequence, the
"Already have 1 record(s)" code path no longer exists.

The CLI has been updated to remove the options and output related to the above
features.

The Use and CancelUse messages are no longer supported.

Database schema changes: The path, expiration time, and deleted columns of
srmspacefile have been deleted, together with their indexes. The ALLOCATED
state of srmspacefile records no longer exists.

Target: trunk
Require-notes: yes
Require-book: yes
Acked-by: Paul Millar <paul.millar@desy.de>
Patch: http://rb.dcache.org/r/6691/
  • Loading branch information
gbehrmann committed Mar 14, 2014
1 parent 7fb85dc commit 618a4d6
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 520 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@

import java.io.Serializable;

import diskCacheV111.util.FsPath;
import diskCacheV111.util.PnfsId;

public class File implements Serializable {
private static final long serialVersionUID = 1231338433325990419L;
private long id;
private String voGroup;
private String voRole;
private long spaceId;
private final long spaceId;
private long sizeInBytes;
private long creationTime;
private Long expirationTime;
private FsPath path;
private PnfsId pnfsId;
private FileState state;
private boolean isDeleted;

public File(
long id,
Expand All @@ -28,23 +24,17 @@ public File(
long spaceId,
long sizeInBytes,
long creationTime,
Long expirationTime,
FsPath path,
PnfsId pnfsId,
FileState state,
boolean isDeleted
FileState state
) {
this.id = id;
this.voGroup = voGroup;
this.voRole = voRole;
this.spaceId = spaceId;
this.sizeInBytes = sizeInBytes;
this.creationTime = creationTime;
this.expirationTime = expirationTime;
this.path = path;
this.pnfsId = pnfsId;
this.state = state;
this.isDeleted = isDeleted;
}

public FileState getState() {
Expand All @@ -68,10 +58,6 @@ public long getSpaceId() {
return spaceId;
}

public void setSpaceId(long spaceId) {
this.spaceId = spaceId;
}

public long getSizeInBytes() {
return sizeInBytes;
}
Expand All @@ -88,22 +74,6 @@ public void setCreationTime(long creationTime) {
this.creationTime = creationTime;
}

public Long getExpirationTime() {
return expirationTime;
}

public void setExpirationTime(Long expirationTime) {
this.expirationTime = expirationTime;
}

public FsPath getPath() {
return path;
}

public void setPath(FsPath path) {
this.path = path;
}

public PnfsId getPnfsId() {
return pnfsId;
}
Expand All @@ -118,12 +88,8 @@ public String toString() {
spaceId+" "+
sizeInBytes+" "+
creationTime+" "+
expirationTime+" "+
path +" "+
pnfsId+" "+
state+" "+
isDeleted +" ";

state;
}

public String getVoGroup() {
Expand All @@ -142,19 +108,6 @@ public void setVoRole(String voRole) {
this.voRole = voRole;
}

public void setDeleted(boolean value) {
this.isDeleted = value;
}

public boolean isDeleted() {
return this.isDeleted;
}

public boolean isExpired()
{
return (state == FileState.ALLOCATED || state == FileState.TRANSFERRING) && expirationTime != null && expirationTime < System.currentTimeMillis();
}

public static Function<File, Long> getSpaceToken =
new Function<File, Long>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,21 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING

public enum FileState
{
/**
* ALLOCATED file reservations are bound to a path, but have not yet
* been created in the name space and thus do not have a PNFS ID.
* The space is tracked as allocated in the space reservation.
*/
ALLOCATED(0),

/**
* TRANSFERRING file reservations are bound to a PNFS ID, thus the
* name space entry has been created, but the file has not finished
* uploading yet. If the file reservation was created in ALLOCATED
* first, then the reservation will also have path. The space is
* tracked as allocated in the space reservation.
* uploading yet. The space is tracked as allocated in the space
* reservation.
*/
TRANSFERRING(1),

/**
* STORED file reservations are bound to a PNFS ID and do not have a
* path. The file has been completely uploaded to dCache and resides
* The file has been completely uploaded to dCache and resides
* on disk. The space is tracked as used in the space reservation.
*/
STORED(2),

/**
* FLUSHED file reservations are bound to a PNFS ID and not to a path.
* The file has been flushed to tape and purged from the space. The
* space is not tracked by the space reservation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Set;

import diskCacheV111.util.AccessLatency;
import diskCacheV111.util.FsPath;
import diskCacheV111.util.PnfsId;
import diskCacheV111.util.RetentionPolicy;
import diskCacheV111.util.VOInfo;
Expand Down Expand Up @@ -104,11 +103,8 @@ public class JdbcSpaceManagerDatabase extends JdbcDaoSupport implements SpaceMan
spacereservationid | bigint | not null
sizeinbytes | bigint | not null
creationtime | bigint | not null
expirationtime | bigint |
pnfspath | character varying(32672) | unique
pnfsid | character varying(36) | unique
state | integer | not null
deleted | integer |
*/
private static final String SPACEFILE_TABLE = "srmspacefile";

Expand Down Expand Up @@ -168,18 +164,14 @@ public LinkGroup mapRow(ResultSet set, int rowNum) throws SQLException
public File mapRow(ResultSet set, int rowNum) throws SQLException
{
String pnfsId = set.getString("pnfsId");
String path = set.getString("pnfspath");
return new File(set.getLong("id"),
set.getString("vogroup"),
set.getString("vorole"),
set.getLong("spacereservationid"),
set.getLong("sizeinbytes"),
set.getLong("creationtime"),
toNull(set.getLong("expirationtime"), set.wasNull()),
(path != null) ? new FsPath(path) : null,
(pnfsId != null) ? new PnfsId(pnfsId) : null,
FileState.valueOf(set.getInt("state")),
(set.getObject("deleted") != null) && set.getInt("deleted") == 1);
FileState.valueOf(set.getInt("state")));
}
};

Expand Down Expand Up @@ -279,18 +271,6 @@ public File selectFileForUpdate(long id) throws DataAccessException
}
}

@Override @Transactional(propagation = Propagation.MANDATORY, noRollbackFor = EmptyResultDataAccessException.class)
public File selectFileForUpdate(FsPath path)
{
try {
return getJdbcTemplate().queryForObject(
"SELECT * FROM " + SPACEFILE_TABLE + " WHERE pnfspath = ? FOR UPDATE ",
fileMapper, path.toString());
} catch (EmptyResultDataAccessException e) {
throw new EmptyResultDataAccessException("Space reservation for " + path + " not found.", 1, e);
}
}

@Override
public Space updateSpace(Space space)
throws DataAccessException
Expand Down Expand Up @@ -525,15 +505,12 @@ public void updateFile(File f)
{
int rc = getJdbcTemplate().update(
"UPDATE " + SPACEFILE_TABLE +
" SET vogroup=?, vorole=?, sizeinbytes=?, expirationtime=?, pnfspath=?, pnfsid=?, state=?, deleted=? WHERE id=?",
" SET vogroup=?, vorole=?, sizeinbytes=?, pnfsid=?, state=? WHERE id=?",
f.getVoGroup(),
f.getVoRole(),
f.getSizeInBytes(),
f.getExpirationTime(),
Objects.toString(f.getPath(), null),
Objects.toString(f.getPnfsId(), null),
f.getState().getStateId(),
f.isDeleted() ? 1 : 0,
f.getId());
if (rc != 1) {
throw new JdbcUpdateAffectedIncorrectNumberOfRowsException("Update failed, row count=" + rc, 1, rc);
Expand Down Expand Up @@ -744,14 +721,6 @@ public File findFile(PnfsId pnfsId) throws DataAccessException
return DataAccessUtils.singleResult(results);
}

@Override
public File findFile(FsPath path) throws DataAccessException
{
List<File> results = getJdbcTemplate().query("SELECT * FROM " + SPACEFILE_TABLE + " WHERE pnfspath=?",
fileMapper, path.toString());
return DataAccessUtils.singleResult(results);
}

@Override
public LinkGroupCriterion linkGroups()
{
Expand Down Expand Up @@ -842,8 +811,6 @@ public long insertFile(final long reservationId,
final String voGroup,
final String voRole,
final long sizeInBytes,
final long lifetime,
final FsPath path,
final PnfsId pnfsId,
final FileState state)
throws DataAccessException, SpaceException
Expand Down Expand Up @@ -878,17 +845,15 @@ public PreparedStatement createPreparedStatement(Connection con) throws SQLExcep
*/
PreparedStatement stmt = con.prepareStatement(
"INSERT INTO " + SPACEFILE_TABLE
+ " (vogroup,vorole,spacereservationid,sizeinbytes,creationtime,expirationtime,pnfspath,pnfsid,state,deleted) "
+ " VALUES (?,?,?,?,?,?,?,?,?,0)", Statement.RETURN_GENERATED_KEYS);
+ " (vogroup,vorole,spacereservationid,sizeinbytes,creationtime,pnfsid,state) "
+ " VALUES (?,?,?,?,?,?,?)", Statement.RETURN_GENERATED_KEYS);
stmt.setString(1, voGroup);
stmt.setString(2, voRole);
stmt.setLong(3, reservationId);
stmt.setLong(4, sizeInBytes);
stmt.setLong(5, creationTime);
stmt.setObject(6, (lifetime == -1) ? null : creationTime + lifetime);
stmt.setString(7, Objects.toString(path, null));
stmt.setString(8, Objects.toString(pnfsId, null));
stmt.setInt(9, state.getStateId());
stmt.setString(6, Objects.toString(pnfsId, null));
stmt.setInt(7, state.getStateId());
return stmt;
}
}, keyHolder);
Expand Down Expand Up @@ -1112,20 +1077,6 @@ public FileCriterion whereStateIsIn(FileState... states)
return this;
}

@Override
public FileCriterion whereDeletedIs(boolean deleted)
{
addClause("deleted = ?", deleted ? 1 : 0);
return this;
}

@Override
public FileCriterion wherePathMatches(Glob pattern)
{
whereFieldMatches("pnfspath", pattern);
return this;
}

@Override
public FileCriterion wherePnfsIdIs(PnfsId pnfsId)
{
Expand All @@ -1141,13 +1092,6 @@ public FileCriterion in(SpaceCriterion spaceCriterion)
return this;
}

@Override
public FileCriterion thatExpireBefore(long millis)
{
addClause("expirationtime < ?", millis);
return this;
}

@Override
public FileCriterion whereCreationTimeIsBefore(long millis)
{
Expand Down
Loading

0 comments on commit 618a4d6

Please sign in to comment.