Skip to content

Commit

Permalink
Issue OpenLiberty#8611 remove unused methods from DatabaseTaskStore
Browse files Browse the repository at this point in the history
  • Loading branch information
njr-11 committed Jan 9, 2020
1 parent 834f54f commit 454fd1f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.sql.SQLIntegrityConstraintViolationException;
import java.sql.SQLTimeoutException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -840,38 +839,6 @@ public Long getPartition(long taskId) throws Exception {
return partitionId;
}

/** {@inheritDoc} */
@Override
public Long getPartitionWithState(long stateBits) throws Exception {
String select = "SELECT p.ID,p.EXECUTOR,p.HOSTNAME,p.ID,p.LSERVER,p.USERDIR,p.EXPIRY,p.STATES FROM Partition p WHERE p.STATES-p.STATES/:d*:d=:r AND p.EXPIRY>:t ORDER BY p.EXPIRY DESC";

final boolean trace = TraceComponent.isAnyTracingEnabled();
if (trace && tc.isEntryEnabled())
Tr.entry(this, tc, "getPartitionWithState", stateBits, select);

long denominator = stateBits < 2 ? 2 : stateBits < 4 ? 4 : -1;
if (denominator == -1)
throw new IllegalArgumentException(Long.toString(stateBits)); // internal error: no states > 3 are currently defined

Object[] partitionInfo;
EntityManager em = getPersistenceServiceUnit().createEntityManager();
try {
TypedQuery<Object[]> query = em.createQuery(select.toString(), Object[].class);
query.setParameter("d", denominator);
query.setParameter("r", stateBits);
query.setParameter("t", System.currentTimeMillis());
query.setMaxResults(1);
List<Object[]> results = query.getResultList();
partitionInfo = results == null || results.isEmpty() ? null : results.get(0);
} finally {
em.close();
}

if (trace && tc.isEntryEnabled())
Tr.exit(this, tc, "getPartitionWithState", partitionInfo == null ? null : Arrays.toString(partitionInfo));
return partitionInfo == null ? null : (Long) partitionInfo[0];
}

/**
* Returns the persistence service unit, lazily initializing if necessary.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014, 2019 IBM Corporation and others.
* Copyright (c) 2014, 2020 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -238,17 +238,6 @@ List<TaskStatus<?>> findTaskStatus(String pattern, Character escape, TaskState s
*/
Long getPartition(long taskId) throws Exception;

/**
* Returns the identifier of a partition whose STATE field's rightmost bits matches the specified value.
* This method assumes that the sign bit of the persisted STATES field is always positive (0),
* so as to be able to compute the remainder when dividing by the next highest power of 2.
*
* @param stateBits desired state bits to match.
* @return a matching partition identifier, otherwise null.
* @throws Exception if an error occurs accessing the persistent store.
*/
Long getPartitionWithState(long stateBits) throws Exception;

/**
* Returns name/value pairs for all persisted properties that match the specified name pattern.
* For example, to find property names that start with "MY_PROP_NAME_",
Expand Down

0 comments on commit 454fd1f

Please sign in to comment.