Skip to content

Commit

Permalink
Merge pull request #383 from aol/cyclopsX-Actual
Browse files Browse the repository at this point in the history
Upgrade to Cyclops X
  • Loading branch information
johnmcclean authored Nov 1, 2017
2 parents 34a2b50 + e40556d commit b473f2c
Show file tree
Hide file tree
Showing 166 changed files with 668 additions and 860 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ buildscript {
}

}

dependencies {
classpath 'com.bmuschko:gradle-nexus-plugin:2.2'
classpath 'com.github.lkishalmi.gradle:gradle-bom-plugin:0.3'
Expand All @@ -28,6 +27,7 @@ subprojects {


apply plugin:'java'
apply plugin:'groovy'
// apply plugin: 'com.github.johnrengelman.shadow'
if(project.name != "micro-tutorial") {
apply plugin: 'com.bmuschko.nexus'
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ springVersion=4.3.3.RELEASE
springBootVersion=1.4.1.RELEASE
jerseyVersion=2.24
grizzlyVersion=2.3.28
cyclopsReactVersion=2.0.0-FINAL
cyclopsVersion=9.0.0-MI6
cyclopsVersion=10.0.0-M1
hamcrestVersion=1.3
hibernateVersion=5.1.0.Final
hibernateValidator=5.2.4.Final
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
import java.util.Iterator;
import java.util.List;

import com.oath.cyclops.types.persistent.PersistentList;
import cyclops.data.Seq;
import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;

import org.pcollections.ConsPStack;
import org.pcollections.PStack;

import com.aol.micro.server.rest.jackson.JacksonUtil;

@FieldDefaults(makeFinal=true, level=AccessLevel.PRIVATE)
public class Application implements Iterable<RegisterEntry>{


PStack<RegisterEntry> entries;
PersistentList<RegisterEntry> entries;

public Application(final List<RegisterEntry> entries) {
this.entries = ConsPStack.from(entries);
this.entries = Seq.fromIterable(entries);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.aol.cyclops2.util.ExceptionSoftener;
import com.oath.cyclops.util.ExceptionSoftener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import cyclops.collections.mutable.ListX;
import org.apache.commons.io.FileUtils;
import org.pcollections.ConsPStack;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -54,6 +55,6 @@ private List<RegisterEntry> findDir(File dir) {
}
}
});
return ConsPStack.from(result);
return ListX.fromIterable(result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.jar.Manifest;

import cyclops.function.FluentFunctions;
import cyclops.stream.ReactiveSeq;
import cyclops.reactive.ReactiveSeq;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;

import cyclops.stream.ReactiveSeq;
import cyclops.reactive.ReactiveSeq;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.aol.micro.server.application.registry;

import cyclops.stream.ReactiveSeq;
import cyclops.reactive.ReactiveSeq;

import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
import com.aol.micro.server.application.registry.ServiceRegistryResource;
import com.aol.micro.server.application.registry.RegistryStatsChecker;
import cyclops.collections.immutable.PersistentSetX;
import cyclops.collections.mutable.SetX;

import java.util.Set;

public class ApplicationRegistryPlugin implements Plugin {

@Override
public PersistentSetX<Class> springClasses() {
return PersistentSetX.of(ApplicationRegisterImpl.class, Cleaner.class, Register.class, ServiceRegistryResource.class,
public Set<Class> springClasses() {
return SetX.of(ApplicationRegisterImpl.class, Cleaner.class, Register.class, ServiceRegistryResource.class,
RegisterConfig.class, Job.class, Finder.class, RegistryHealthChecker.class, RegistryStatsChecker.class);
}

Expand Down
2 changes: 1 addition & 1 deletion micro-async-data-loader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repositories {
}

dependencies {
compile ("com.aol.simplereact:cyclops-react:$cyclopsReactVersion")
compile ("com.oath.cyclops:cyclops:$cyclopsVersion")
compile project(':micro-events')
compile project(':micro-manifest-comparator')
testCompile project(':micro-grizzly-with-jersey')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import cyclops.collections.mutable.ListX;
import cyclops.collections.mutable.SetX;
import cyclops.stream.ReactiveSeq;
import cyclops.reactive.ReactiveSeq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.google.common.eventbus.EventBus;

import cyclops.collections.mutable.ListX;
import cyclops.stream.ReactiveSeq;
import cyclops.reactive.ReactiveSeq;
import lombok.AllArgsConstructor;

@AllArgsConstructor
Expand Down
2 changes: 1 addition & 1 deletion micro-async-data-writer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repositories {
}

dependencies {
compile ("com.aol.simplereact:cyclops-react:$cyclopsReactVersion")
compile ("com.oath.cyclops:cyclops:$cyclopsVersion")
compile project(':micro-events')
compile project(':micro-manifest-comparator')
testCompile project(':micro-grizzly-with-jersey')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.google.common.eventbus.EventBus;

import cyclops.collections.mutable.ListX;
import cyclops.stream.ReactiveSeq;
import cyclops.reactive.ReactiveSeq;
import lombok.AllArgsConstructor;

@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private ListX<DataCleaner> dataCleaners() {
Maybe<DataCleaner> defaultDataCleaner = defaultComparators.size() == 1 ? Maybe.just(new DataCleaner(
defaultComparators.get(0),
defaultCronCleaner))
: Maybe.none();
: Maybe.nothing();
return ListX.fromIterable(defaultDataCleaner)
.plusAll(dataCleaners);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import cyclops.async.Future;
import cyclops.collections.mutable.MapX;
import org.jooq.lambda.tuple.Tuple;
import cyclops.data.tuple.Tuple;


import com.aol.micro.server.events.SystemData;
Expand Down Expand Up @@ -48,7 +48,7 @@ public Future<T> loadAndGet() {
.correlationId(correlationId)
.dataMap(dataMap.get())
.errors(0)
.processed(t.v1 ? 1 : 0)
.processed(t._1() ? 1 : 0)
.build())) // add
// recover
// option
Expand All @@ -57,7 +57,7 @@ public Future<T> loadAndGet() {
// with
// cyclops-react
// 1.0.0-final
.map(t -> t.v2);
.map(t -> t._2());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ public String bucket() {
public String get() {

return comparator.loadAndGet()
.get();
.visit(s->s,e->"Error loading " + e.getMessage());

}


@GET
@Path("/check")
public String check() {
return "" + !comparator.isOutOfDate()
.get();
.getOrElse(null);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.concurrent.atomic.AtomicInteger;

import cyclops.async.Future;
import cyclops.control.Option;
import cyclops.control.Try;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -46,7 +48,7 @@ public void testLoadAndGet() {
dummyMc.setData("hello world");
Future<String> res = writer.loadAndGet();

assertThat(res.get(), equalTo("hello world"));
assertThat(res.get(), equalTo(Try.success("hello world")));
assertThat(dummyMc.loadCalled.get(), equalTo(1));
assertThat(eventRecieved.get(), equalTo(1));
}
Expand All @@ -56,7 +58,7 @@ public void testSaveAndIncrement() {
assertThat(eventRecieved.get(), equalTo(0));
writer.saveAndIncrement("boo!");
Future<String> res = writer.loadAndGet();
assertThat(res.get(), equalTo("boo!"));
assertThat(res.get(), equalTo(Try.success("boo!")));
assertThat(eventRecieved.get(), equalTo(2));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.junit.Assert.assertThat;

import cyclops.collections.mutable.ListX;
import cyclops.control.Try;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -31,32 +32,33 @@ public void bothDataWritersUpdated() {
writer.saveAndIncrement("hello world");
assertThat(dataWriter1.loadAndGet()
.get(),
equalTo("hello world"));
equalTo(Try.success("hello world")));
assertThat(dataWriter2.loadAndGet()
.get(),
equalTo("hello world"));
equalTo(Try.success("hello world")));
}

@Test
public void emptySaveAndIncrement() {

assertThat(empty.saveAndIncrement("hello world")
.get(),
equalTo(null));
equalTo(Try.success(null)));
}

@Test
public void loadAndGetReturnsDataFromFirst() {
dataWriter1.setData("one");
dataWriter2.setData("two");
String data = writer.loadAndGet()
.get();
.orElse(null);
assertThat(data, equalTo("one"));
}

@Test
public void loadAndGetReturnsNullForEmpty() {
String data = empty.loadAndGet()
.get();
.orElse("null!!");
assertThat(data, equalTo(null));
}

Expand All @@ -65,7 +67,7 @@ public void isOutOfDateReturnsFalseIfSecondOnlyIsFalse() {
dataWriter1.setOutofdate(true);
dataWriter2.setOutofdate(false);
boolean outofdate = writer.isOutOfDate()
.get();
.orElse(null);
assertThat(outofdate, equalTo(true));
}

Expand All @@ -74,7 +76,7 @@ public void isOutOfDateReturnsFalseIfFirstOnlyIsFalse() {
dataWriter1.setOutofdate(false);
dataWriter2.setOutofdate(true);
boolean outofdate = writer.isOutOfDate()
.get();
.orElse(null);
assertThat(outofdate, equalTo(true));
}

Expand All @@ -83,24 +85,27 @@ public void isOutOfDateReturnsFalseIfBothAreFalse() {
dataWriter1.setOutofdate(false);
dataWriter2.setOutofdate(false);
boolean outofdate = writer.isOutOfDate()
.get();
.orElse(null);
assertThat(outofdate, equalTo(false));
}

@Test
public void isOutOfDateReturnsTrueIfBothAreTrue() {
dataWriter1.setOutofdate(true);
dataWriter2.setOutofdate(true);

boolean outofdate = writer.isOutOfDate()
.get();
.orElse(null);


assertThat(outofdate, equalTo(true));
}

@Test
public void isOutofDateWorksEmpty() {

boolean outofdate = empty.isOutOfDate()
.get();
.orElse(null);
assertThat(outofdate, equalTo(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.Optional;
import java.util.concurrent.ExecutionException;

import com.aol.cyclops2.types.futurestream.SimpleReactStream;
import com.oath.cyclops.types.futurestream.SimpleReactStream;
import cyclops.async.SimpleReact;
import org.junit.After;
import org.junit.Before;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

import com.aol.micro.server.Plugin;
import cyclops.collections.immutable.PersistentSetX;
import cyclops.collections.mutable.SetX;

import java.util.Set;

/**
*
Expand All @@ -12,8 +15,8 @@
public class ClientPlugin implements Plugin{

@Override
public PersistentSetX<Class> springClasses() {
return PersistentSetX.of(SpringConfig.class);
public Set<Class> springClasses() {
return SetX.of(SpringConfig.class);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import java.util.Arrays;

import cyclops.stream.ReactiveSeq;
import cyclops.reactive.ReactiveSeq;
import org.junit.Test;


Expand Down
Loading

0 comments on commit b473f2c

Please sign in to comment.