Skip to content

Commit

Permalink
Merge branch 'release/UV_Core_v1.5.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Klempa committed Feb 10, 2015
2 parents a666ffb + 522a801 commit 3c7298b
Show file tree
Hide file tree
Showing 76 changed files with 1,720 additions and 751 deletions.
10 changes: 10 additions & 0 deletions backend/conf/config.sample.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,20 @@ backend.host = 127.0.0.1
backend.port = 5010

# Connection configuration setting for relational database
# for mysql {
database.sql.driver = com.mysql.jdbc.Driver
database.sql.url = jdbc:mysql://localhost:3306/unifiedviews?characterEncoding=utf8
database.sql.user = unifiedviews
database.sql.password = unifiedviews
# }

# for postgresql {
database.sql.driver = org.postgresql.Driver
database.sql.url = jdbc:postgresql://localhost:5432/unifiedviews
database.sql.user = unifiedviews
database.sql.password = unifiedviews
# }


# Connection configuration setting for RDF database
# use local rdf platform {
Expand Down
2 changes: 1 addition & 1 deletion backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>cz.cuni.mff.xrg.odcs</groupId>
<artifactId>odcs</artifactId>
<version>1.5.0</version>
<version>1.5.5</version>
</parent>
<artifactId>backend</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.StringWriter;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -107,6 +108,8 @@ public class Context implements DPUContext {
*/
private boolean canceled;

private Locale locale;

/**
* True if the execution should be stopped on DPU's request. The execution
* does not failed instantly by this.
Expand All @@ -123,6 +126,7 @@ public Context() {
this.errorMessage = false;
this.canceled = false;
this.stopExecution = false;
this.locale = null;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - //
Expand Down Expand Up @@ -360,4 +364,13 @@ public String getDpuInstanceDirectory() {
result.mkdirs();
return result.toURI().toASCIIString();
}

@Override
public Locale getLocale() {
return locale;
}

public void setLocale(Locale locale) {
this.locale = locale;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.util.Date;
import java.util.Locale;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
Expand All @@ -11,12 +12,15 @@
import cz.cuni.mff.xrg.odcs.commons.app.conf.ConfigProperty;
import cz.cuni.mff.xrg.odcs.commons.app.dpu.DPUInstanceRecord;
import cz.cuni.mff.xrg.odcs.commons.app.execution.context.ExecutionContextInfo;
import cz.cuni.mff.xrg.odcs.commons.app.facade.RuntimePropertiesFacade;
import cz.cuni.mff.xrg.odcs.commons.app.properties.RuntimeProperty;
import eu.unifiedviews.dataunit.DataUnit;

/**
* Component that is used to create {@link Context} for give {@link DPUInstanceRecord} and {@link ExecutionContextInfo}.
* If context has some previous data ie. {@link ExecutionContextInfo} is not
* empty data are not loaded. To load data use {@link ContextRestore}
*
*
* @author Petyr
*/
abstract class ContextCreator {
Expand All @@ -30,13 +34,19 @@ abstract class ContextCreator {
@Autowired
private AppConfig appConfig;

/**
* Runtime properties facade.
*/
@Autowired
protected RuntimePropertiesFacade runtimePropertiesFacade;

@Autowired
private AutowireCapableBeanFactory autowireBeanFactory;

/**
* Create context for given {@link DPUInstanceRecord} and {@link ExecutionContextInfo}. The context is ready for use. Data from {@link ExecutionContextInfo}
* are not loaded into context.
*
*
* @param dpuInstance
* @param contextInfo
* @param lastSuccExec
Expand All @@ -51,6 +61,12 @@ public Context createContext(DPUInstanceRecord dpuInstance,
newContext.setDPU(dpuInstance);
newContext.setContextInfo(contextInfo);
newContext.setLastSuccExec(lastSuccExec);
String localeName = "en_US";
RuntimeProperty localeNameProperty = runtimePropertiesFacade.getByName("locale");
if (localeNameProperty != null) {
localeName = localeNameProperty.getValue();
}
newContext.setLocale(new Locale(localeName));

// prepare DataUnitManagers
final File workingDir = new File(
Expand All @@ -69,7 +85,7 @@ public Context createContext(DPUInstanceRecord dpuInstance,

/**
* Method for spring that create new {@link Context}.
*
*
* @return
*/
protected abstract Context createPureContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;

import ch.qos.logback.classic.Level;
Expand All @@ -36,7 +35,7 @@
/**
* Implementation of log appender. The code is inspired by {@link ch.qos.logback.core.db.DBAppenderBase}.
* The appender is designed to append into single table in Virtuoso.
*
*
* @author Petr Škoda
*/
public class SqlAppenderImpl extends UnsynchronizedAppenderBase<ILoggingEvent>
Expand Down Expand Up @@ -95,19 +94,19 @@ public class SqlAppenderImpl extends UnsynchronizedAppenderBase<ILoggingEvent>

/**
* Return string that is used as insert query into logging table.
*
*
* @return SQL command used to the insert data to the database.
*/
private String getInsertSQL() {
return "INSERT INTO logging"
+ " (logLevel, timestmp, logger, message, dpu, execution, stack_trace, relative_id)"
+ " (log_level, timestmp, logger, message, dpu, execution, stack_trace, relative_id)"
+ " VALUES (?, ?, ? ,?, ?, ?, ?, ?)";
}

/**
* Return not null {@link Connection}. If failed to get connection then
* continue to try until success.
*
*
* @return Connection to the database.
*/
private Connection getConnection() {
Expand All @@ -117,7 +116,7 @@ private Connection getConnection() {
connection = connectionSource.getConnection();
connection.setAutoCommit(false);
} catch (SQLException ex) {
// wait for some time an try it again ..
// wait for some time an try it again ..
LOG.error("Failed to get sql connection, next try in second.", ex);
try {
Thread.sleep(1000);
Expand All @@ -131,7 +130,7 @@ private Connection getConnection() {

/**
* Store given logs into database.
*
*
* @param connection
* @param logs
* @return True only if all logs has been saved into database.
Expand All @@ -150,9 +149,9 @@ private boolean flushIntoDatabase(Connection connection, List<ILoggingEvent> log
connection.commit();
} catch (BatchUpdateException sqle) {
LOG.error("Failed to save logs into database. Given logs will not be saved.", sqle);
// also reset the counter, as it may count logs that are not in
// also reset the counter, as it may count logs that are not in
// database .. this will force some queris into database
// but as we do not know which logs passed and which not we
// but as we do not know which logs passed and which not we
// have to do this
relativeIdHolder.resetIdCounters();
return true;
Expand Down Expand Up @@ -231,7 +230,7 @@ public synchronized void flush() {
Connection connection = getConnection();

// update next try based on result
// if the save failed, we try it again ..
// if the save failed, we try it again ..
while (toFetch != null) {
// if one of them failed, then we instantly end,
// close connection, get new one .. and give
Expand All @@ -252,7 +251,7 @@ public synchronized void flush() {
toFetch = null;
}
} catch (Exception ex) {
// just for sure ..
// just for sure ..
LOG.error("Iterator throws!!!", ex);
}

Expand All @@ -275,7 +274,7 @@ public synchronized void flush() {
/**
* Do immediate write of given log into database. If the database is down
* then the log is not saved.
*
*
* @param eventObject
*/
private void appendImmediate(ILoggingEvent eventObject) {
Expand Down Expand Up @@ -345,7 +344,7 @@ public void start() {
public void append(ILoggingEvent eventObject) {

if (supportsBatchUpdates) {
// we can use batch .. so we just add the logs into
// we can use batch .. so we just add the logs into
// the queue
synchronized (lockList) {
primaryList.add(eventObject);
Expand All @@ -357,15 +356,15 @@ public void append(ILoggingEvent eventObject) {

/**
* Bind the parameters to he insert statement.
*
*
* @param event
* @param stmt
* @throws Throwable
*/
protected synchronized void bindStatement(ILoggingEvent event,
PreparedStatement stmt) throws Throwable {

/* ! ! ! ! ! ! ! ! !
/* ! ! ! ! ! ! ! ! !
* As the message and stackTrace are BLOBS interpreted as string they
* must not be empty -> they have to be null or have some content
*/
Expand Down Expand Up @@ -431,7 +430,7 @@ protected synchronized void bindStatement(ILoggingEvent event,

/**
* Convert information about stack trace into text form.
*
*
* @param proxy
* @param sb
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public class SchedulerTest {

@Autowired
private ScheduleFacade scheduleFacade;

private class EngineMockWithLimit extends EngineMock {
@Override
protected Integer getLimitOfScheduledPipelines() {
return RUNNIG_PPL_LIMIT;
}
}

@Test
@Transactional
public void test() {
Expand Down Expand Up @@ -107,7 +107,6 @@ public Schedule createSchedule(int priority, Pipeline ppl) {
public void test3() {
Pipeline ppl = pipelineFacade.createPipeline();
pipelineFacade.save(ppl);

Schedule schedule = createSchedule(0, ppl);
Schedule schedule2 = createSchedule(0, ppl);
Schedule schedule3 = createSchedule(0, ppl);
Expand Down
4 changes: 3 additions & 1 deletion backend/src/test/resources/backend-test-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

<!-- listener for watching events -->
<bean class="cz.cuni.mff.xrg.odcs.backend.spring.InMemoryEventListener"/>
<!-- Facade for managing runtime properties -->
<bean id="runtimePropertiesFacade" class="cz.cuni.mff.xrg.odcs.commons.app.facade.RuntimePropertiesFacadeImpl"/>

<!-- dummy DataUnit factory -->
<bean class="cz.cuni.mff.xrg.odcs.backend.spring.DummyDataUnitFactory"/>
Expand Down Expand Up @@ -55,7 +57,6 @@
<property name="entityManagerFactory" ref="emf"/>
</bean>


<jdbc:embedded-database id="dataSource" type="H2">
<jdbc:script location="classpath:db/schema.sql"/>
<jdbc:script location="classpath:db/data.sql"/>
Expand All @@ -81,6 +82,7 @@
<bean id="dbUserNotification" class="cz.cuni.mff.xrg.odcs.commons.app.user.DbUserNotificationRecordImpl"/>
<bean id="dbUser" class="cz.cuni.mff.xrg.odcs.commons.app.user.DbUserImpl"/>
<bean id="dbNamespacePrefix" class="cz.cuni.mff.xrg.odcs.commons.app.rdf.namespace.DbNamespacePrefixImpl"/>
<bean id="dbRuntimeProperties" class="cz.cuni.mff.xrg.odcs.commons.app.properties.DbRuntimePropertiesImpl"/>
<!-- scan for pre/post executors -->
<context:component-scan base-package="cz.cuni.mff.xrg.odcs.backend.execution.dpu.impl"/>

Expand Down
15 changes: 13 additions & 2 deletions commons-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>cz.cuni.mff.xrg.odcs</groupId>
<artifactId>odcs</artifactId>
<version>1.5.0</version>
<version>1.5.5</version>
</parent>
<artifactId>commons-app</artifactId>
<name>commons-app</name>
Expand Down Expand Up @@ -239,10 +239,15 @@
<!-- END OF SPRING DEPENDENCIES -->

<!-- Embedded database used for testing -->
<dependency>
<!-- <dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.171</version>
</dependency> -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.182</version>
</dependency>

<!-- EclipseLink dependencies -->
Expand Down Expand Up @@ -305,6 +310,12 @@
<version>4.8.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1102-jdbc41</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public enum ConfigProperty {
BACKEND_LOG_KEEP("backend.log.keepDays"),
BACKEND_DEFAULTRDF("backend.defaultRdf"),
BACKEND_LIMIT_OF_SCHEDULED_PIPELINES("backend.scheduledPipelines.limit"),
LOCALE("locale"),

EXECUTION_LOG_HISTORY("exec.log.history"),
EXECUTION_LOG_SIZE_MAX("exec.log.msg.maxSize"),
Expand Down
Loading

0 comments on commit 3c7298b

Please sign in to comment.