Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added alitheia/core/alitheia.log
Empty file.
Empty file added alitheia/core/hibernate.log
Empty file.
Empty file added alitheia/core/perf.log
Empty file.
16 changes: 16 additions & 0 deletions alitheia/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@
</build>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.14.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
Expand Down
Empty file added alitheia/core/rest.log
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -95,61 +95,14 @@ public String getClusterNodeName(){
return thisNode.getName();
}

/**
* Assign a StoredProject to a ClusterNode
* Reasonable causes of failure:
* 1.NULL passed server
* 2.NULL passed project
* 3.Assignment is locked (server is working on project)
*
* @param node the cluster node target
* @param project stored project to assign
* @return
*/
public boolean assignProject(ClusterNode node, StoredProject project) throws ClusterNodeActionException {
// check if valid server passed
if (node==null) {
throw new ClusterNodeActionException("Request to assign a project to a null clusternode");
}
// check if valid project passed
if (project==null) {
throw new ClusterNodeActionException("Request to assign a null project to a clusternode");
}

try {
// check if project is already assigned to any ClusterNode
ClusterNode assignment = project.getClusternode();
if (assignment == null) {
// new project assignment
logger.info("Assigning project " + project.getName() + " to "
+ node.getName());
node.getProjects().add(project);
} else {
logger.info("Moving project " + project.getName() + " from "
+ assignment.getName() + " to "
+ node.getName());
if (assignment.getId() == node.getId()) {
logger.info("No need to move " + project.getName()
+ " - Already assigned!");
return true;
}
}
} catch (Exception e) {
throw new ClusterNodeActionException("Failed to assign project ["
+ project.getName() + "] to clusternode [" + node.getName()
+ "]");
}
return true;
}

/**
* Assign a StoredProject to this ClusterNode
* @param project project to assign
* @return
*/
public boolean assignProject(StoredProject project) throws ClusterNodeActionException {
try {
return assignProject(thisNode, project);
return thisNode.assignProject(logger, thisNode, project);
} catch (ClusterNodeActionException ex) {
throw ex;
}
Expand Down Expand Up @@ -316,7 +269,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response)
}
}
try {
if (assignProject(node,project)){
if (thisNode.assignProject(logger, node, project)){
content = createXMLResponse(null, "Project " + project.getName() + " assigned to " + node.getName(), HttpServletResponse.SC_OK);
sendXMLResponse(response, HttpServletResponse.SC_OK, content);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public class DBServiceImpl implements DBService, AlitheiaCoreService {
private AtomicBoolean isInitialised = new AtomicBoolean(false);
private Properties conProp = new Properties();

private void logSQLException(SQLException e) {
protected void logSQLException(SQLException e) {

while (e != null) {
String message = String.format("SQLException: SQL State:%s, Error Code:%d, Message:%s",
Expand All @@ -136,7 +136,7 @@ private void logSQLException(SQLException e) {
}
}

private void logExceptionAndTerminateSession( Exception e ) {
protected void logExceptionAndTerminateSession( Exception e ) {
if ( e instanceof JDBCException ) {
JDBCException jdbce = (JDBCException) e;
logSQLException(jdbce.getSQLException());
Expand All @@ -159,7 +159,7 @@ private void logExceptionAndTerminateSession( Exception e ) {

}

private boolean checkSession() {
protected boolean checkSession() {
if ( !isDBSessionActive() ) {
logger.warn("Trying to call a DBService method without an active session");
try {
Expand All @@ -172,7 +172,7 @@ private boolean checkSession() {
return true;
}

private boolean getJDBCConnection() {
protected boolean getJDBCConnection() {
String driver = conProp.getProperty("hibernate.connection.driver_class");
try {
Driver d = (Driver)Class.forName(driver).newInstance();
Expand Down Expand Up @@ -210,7 +210,7 @@ private boolean getJDBCConnection() {
}
}

private boolean initHibernate(URL configFileURL) {
protected boolean initHibernate(URL configFileURL) {

logger.info("Initializing Hibernate with URL <" + configFileURL + ">");
if (configFileURL == null) {
Expand Down Expand Up @@ -308,7 +308,7 @@ public <T extends DAObject> T findObjectByIdForUpdate(Class<T> daoClass, long id
}

@SuppressWarnings("unchecked")
private <T extends DAObject> T doFindObjectById(Class<T> daoClass, long id, boolean useLock) {
protected <T extends DAObject> T doFindObjectById(Class<T> daoClass, long id, boolean useLock) {
if ( !checkSession() )
return null;

Expand All @@ -330,7 +330,7 @@ public <T extends DAObject> List<T> findObjectsByPropertiesForUpdate(Class<T> da
}

@SuppressWarnings("unchecked")
private <T extends DAObject> List<T> doFindObjectsByProperties(Class<T> daoClass, Map<String,Object> properties, boolean useLock) {
protected <T extends DAObject> List<T> doFindObjectsByProperties(Class<T> daoClass, Map<String,Object> properties, boolean useLock) {
if( !checkSession() )
return Collections.emptyList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,13 +554,11 @@ public OnDiskCheckout getCheckout(ProjectVersion pv, String path)
// Search for a cached checkout that could be updated
/*Set<String> c = checkoutCache.keySet();
OnDiskCheckoutImpl updatable = null;

for (String s : c) {
if (cacheKeyProject(s).equals(pv.getProject())) {
ProjectVersion cached = cacheKeyProjectVersion(s);
if (cached.lt(pv)) {
updatable = (OnDiskCheckoutImpl) getCheckoutFromCache(cached);

if (checkoutHandles.get(updatable) == 1) {
try {
updateCheckout(updatable, pv);
Expand All @@ -574,7 +572,6 @@ public OnDiskCheckout getCheckout(ProjectVersion pv, String path)
}
}
}

// No updatable checkout found, create
synchronized (pv) {
if (!cacheContains(pv))
Expand Down Expand Up @@ -642,12 +639,10 @@ public void releaseCheckout(OnDiskCheckout c) {
logger.warn("Attempting to release null checkout");
return;
}

if (!checkoutCache.contains(c)) {
logger.warn("Attempting to release not cached checkout");
return;
}

returnCheckout(c);
*/
File root = null;
Expand Down Expand Up @@ -709,4 +704,3 @@ public boolean startUp() {
}

// vi: ai nosi sw=4 ts=4 expandtab

Loading