Yuta HIGUCHI

Workarounds to startup DatabaseService

- shaded copycat
- switched Chronicle log to InMemory log until we fix the OSGi issue

Change-Id: Icf8ee8c18b518a8ee785924413681bdb61fc5037
......@@ -31,6 +31,10 @@
<description>ONOS Gossip based distributed store subsystems</description>
<properties>
<copycat.version>0.4.0-SNAPSHOT</copycat.version>
</properties>
<dependencies>
<dependency>
<groupId>org.onlab.onos</groupId>
......@@ -43,24 +47,25 @@
<artifactId>onlab-netty</artifactId>
<version>${project.version}</version>
</dependency>
<!--
<dependency>
<groupId>net.kuujo.copycat</groupId>
<artifactId>copycat</artifactId>
<version>0.4.0-SNAPSHOT</version>
<version>${copycat.version}</version>
</dependency>
<dependency>
<groupId>net.kuujo.copycat</groupId>
<artifactId>copycat-chronicle</artifactId>
<version>0.4.0-SNAPSHOT</version>
<version>${copycat.version}</version>
</dependency>
<dependency>
<groupId>net.kuujo.copycat</groupId>
<artifactId>copycat-tcp</artifactId>
<version>0.4.0-SNAPSHOT</version>
<version>${copycat.version}</version>
</dependency>
-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
......@@ -95,6 +100,12 @@
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
</dependency>
<!-- for shaded copycat -->
<dependency>
<groupId>org.onlab.onos</groupId>
<artifactId>onlab-thirdparty</artifactId>
</dependency>
</dependencies>
</project>
......
......@@ -64,7 +64,8 @@ import com.google.common.collect.ImmutableSet;
*/
@Component(immediate = true)
@Service
public class ClusterMessagingProtocol implements Protocol<TcpMember> {
public class ClusterMessagingProtocol
implements DatabaseProtocolService, Protocol<TcpMember> {
private final Logger log = getLogger(getClass());
......
......@@ -11,9 +11,8 @@ import net.kuujo.copycat.StateMachine;
import net.kuujo.copycat.cluster.TcpCluster;
import net.kuujo.copycat.cluster.TcpClusterConfig;
import net.kuujo.copycat.cluster.TcpMember;
import net.kuujo.copycat.log.ChronicleLog;
import net.kuujo.copycat.log.InMemoryLog;
import net.kuujo.copycat.log.Log;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
......@@ -52,7 +51,7 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService {
protected ClusterService clusterService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ClusterMessagingProtocol copycatMessagingProtocol;
protected DatabaseProtocolService copycatMessagingProtocol;
public static final String LOG_FILE_PREFIX = "onos-copy-cat-log";
......@@ -61,6 +60,7 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService {
@Activate
public void activate() {
log.info("Starting.");
// TODO: Not every node can be part of the consensus ring.
......@@ -88,7 +88,9 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService {
StateMachine stateMachine = new DatabaseStateMachine();
ControllerNode thisNode = clusterService.getLocalNode();
Log consensusLog = new ChronicleLog(LOG_FILE_PREFIX + "_" + thisNode.id());
// FIXME resolve Chronicle + OSGi issue
//Log consensusLog = new ChronicleLog(LOG_FILE_PREFIX + "_" + thisNode.id());
Log consensusLog = new InMemoryLog();
copycat = new Copycat(stateMachine, consensusLog, cluster, copycatMessagingProtocol);
copycat.start();
......
package org.onlab.onos.store.service.impl;
import net.kuujo.copycat.cluster.TcpMember;
import net.kuujo.copycat.spi.protocol.Protocol;
// interface required for connecting DatabaseManager + ClusterMessagingProtocol
// TODO: Consider changing ClusterMessagingProtocol to non-Service class
public interface DatabaseProtocolService extends Protocol<TcpMember> {
}
/*
* Copyright 2014 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Distributed core state management services.
*/
package org.onlab.onos.store.service;
......
......@@ -56,9 +56,16 @@
<bundle>mvn:org.codehaus.jackson/jackson-mapper-asl/1.9.13</bundle>
<bundle>mvn:org.onlab.onos/onlab-thirdparty/1.0.0-SNAPSHOT</bundle>
<!-- FIXME fix the version before release -->
<!-- FIXME: resolce Chronicle's dependency issue
<bundle>mvn:net.openhft/lang/6.4.6</bundle>
<bundle>mvn:net.openhft/affinity/2.1.1</bundle>
<bundle>mvn:net.openhft/chronicle/3.2.2</bundle>
-->
<!-- things used before shading copycat
<bundle>wrap:mvn:http://mavenrepo.onlab.us:8081/nexus/content/groups/public@id=onlab-temp!net.kuujo.copycat/copycat/0.4.0-SNAPSHOT$Bundle-SymbolicName=net.kuujo.copycat.copycat&amp;Bundle-Version=0.4.0.SNAPSHOT</bundle>
<bundle>wrap:mvn:http://mavenrepo.onlab.us:8081/nexus/content/groups/public@id=onlab-temp!net.kuujo.copycat/copycat-tcp/0.4.0-SNAPSHOT$Bundle-SymbolicName=net.kuujo.copycat.copycat-tcp&amp;Bundle-Version=0.4.0.SNAPSHOT</bundle>
<bundle>wrap:mvn:http://mavenrepo.onlab.us:8081/nexus/content/groups/public@id=onlab-temp!net.kuujo.copycat/copycat-chronicle/0.4.0-SNAPSHOT$Bundle-SymbolicName=net.kuujo.copycat.copycat-chronicle&amp;Bundle-Version=0.4.0.SNAPSHOT</bundle>
-->
</feature>
<feature name="onos-thirdparty-web" version="1.0.0"
......
......@@ -31,12 +31,43 @@
<description>ONLab third-party dependencies</description>
<!-- TODO move to root pom? -->
<properties>
<copycat.version>0.4.0-SNAPSHOT</copycat.version>
</properties>
<dependencies>
<dependency>
<groupId>com.googlecode.concurrent-trees</groupId>
<artifactId>concurrent-trees</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>net.kuujo.copycat</groupId>
<artifactId>copycat</artifactId>
<version>${copycat.version}</version>
</dependency>
<!-- Commented out due to Chronicle + OSGi issue
<dependency>
<groupId>net.kuujo.copycat</groupId>
<artifactId>copycat-chronicle</artifactId>
<version>${copycat.version}</version>
</dependency>
-->
<dependency>
<groupId>net.kuujo.copycat</groupId>
<artifactId>copycat-tcp</artifactId>
<version>${copycat.version}</version>
</dependency>
<!-- chronicle transitive dependency
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.1.0</version>
</dependency>
-->
</dependencies>
<build>
......@@ -47,19 +78,36 @@
<version>2.3</version>
<configuration>
<filters>
<filter>
<artifact>com.googlecode.concurrent-trees:concurrent-trees</artifact>
<includes>
<include>com/googlecode/**</include>
</includes>
</filter>
<filter>
<artifact>com.google.guava:guava</artifact>
<excludes>
<exclude>**</exclude>
</excludes>
</filter>
<filter>
<artifact>net.kuujo.copycat:*</artifact>
<includes>
<include>net/kuujo/copycat/**</include>
</includes>
</filter>
<!-- chronicle transitive dependency
<filter>
<artifact>net.java.dev.jna:*</artifact>
<includes>
<include>com/sun/jna/**</include>
</includes>
</filter>
-->
</filters>
</configuration>
<executions>
......@@ -77,7 +125,7 @@
<configuration>
<instructions>
<Export-Package>
com.googlecode.concurrenttrees.*
com.googlecode.concurrenttrees.*;net.kuujo.copycat.*
</Export-Package>
</instructions>
</configuration>
......