├── logo.png
├── nbactions.xml
├── core
├── src
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── offbynull
│ │ │ └── actors
│ │ │ ├── shuttles
│ │ │ ├── blackhole
│ │ │ │ └── BlackholeShuttleTest.java
│ │ │ ├── simple
│ │ │ │ └── SimpleShuttleTest.java
│ │ │ └── pump
│ │ │ │ └── PumpShuttleTest.java
│ │ │ ├── gateways
│ │ │ ├── actor
│ │ │ │ ├── SerializableActorHelper.java
│ │ │ │ ├── ActorNeighbourSpawnTest.java
│ │ │ │ ├── ContextTest.java
│ │ │ │ └── stores
│ │ │ │ │ └── memory
│ │ │ │ │ └── BestEffortSerializerTest.java
│ │ │ ├── log
│ │ │ │ └── LogGatewayTest.java
│ │ │ ├── timer
│ │ │ │ └── TimerGatewayTest.java
│ │ │ ├── threadpool
│ │ │ │ └── ThreadPoolGatewayTest.java
│ │ │ ├── servlet
│ │ │ │ ├── JsonConverterTest.java
│ │ │ │ └── ServletGatewayTest.java
│ │ │ └── direct
│ │ │ │ └── DirectGatewayTest.java
│ │ │ ├── ActorSystemTest.java
│ │ │ └── address
│ │ │ └── AddressTest.java
│ └── main
│ │ └── java
│ │ └── com
│ │ └── offbynull
│ │ └── actors
│ │ ├── common
│ │ └── package-info.java
│ │ ├── package-info.java
│ │ ├── gateways
│ │ ├── actor
│ │ │ ├── package-info.java
│ │ │ ├── stores
│ │ │ │ └── memory
│ │ │ │ │ └── package-info.java
│ │ │ ├── FailListener.java
│ │ │ ├── Actor.java
│ │ │ └── ActorShuttle.java
│ │ ├── log
│ │ │ ├── package-info.java
│ │ │ ├── LogGateway.java
│ │ │ └── LogRunnable.java
│ │ ├── servlet
│ │ │ ├── package-info.java
│ │ │ ├── stores
│ │ │ │ └── memory
│ │ │ │ │ └── package-info.java
│ │ │ ├── ResponseBlock.java
│ │ │ ├── RequestBlock.java
│ │ │ ├── ServletShuttle.java
│ │ │ ├── AddressServlet.java
│ │ │ └── MessageBridgeServlet.java
│ │ ├── threadpool
│ │ │ ├── package-info.java
│ │ │ ├── ThreadPoolProcessor.java
│ │ │ └── ThreadPoolShuttle.java
│ │ ├── timer
│ │ │ ├── package-info.java
│ │ │ ├── RemoveShuttle.java
│ │ │ ├── AddShuttle.java
│ │ │ └── TimerGateway.java
│ │ └── direct
│ │ │ ├── package-info.java
│ │ │ └── DirectShuttle.java
│ │ ├── address
│ │ └── package-info.java
│ │ ├── gateway
│ │ ├── package-info.java
│ │ ├── CommonAddresses.java
│ │ └── Gateway.java
│ │ ├── shuttle
│ │ ├── package-info.java
│ │ ├── Shuttle.java
│ │ └── Message.java
│ │ └── shuttles
│ │ ├── blackhole
│ │ ├── package-info.java
│ │ └── BlackholeShuttle.java
│ │ ├── simple
│ │ ├── package-info.java
│ │ └── SimpleShuttle.java
│ │ └── pump
│ │ ├── package-info.java
│ │ ├── PumpShuttle.java
│ │ └── PumpShuttleController.java
├── nb-configuration.xml
├── nbactions.xml
└── pom.xml
├── jdbc-storage
├── src
│ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── offbynull
│ │ │ └── actors
│ │ │ ├── jdbcclient
│ │ │ ├── package-info.java
│ │ │ └── JdbcUtils.java
│ │ │ └── gateways
│ │ │ ├── actor
│ │ │ └── stores
│ │ │ │ └── jdbc
│ │ │ │ └── package-info.java
│ │ │ └── servlet
│ │ │ └── stores
│ │ │ └── jdbc
│ │ │ └── package-info.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── offbynull
│ │ └── actors
│ │ ├── gateways
│ │ └── actor
│ │ │ └── SerializableActorHelper.java
│ │ └── ActorSystemTest.java
├── nb-configuration.xml
├── nbactions.xml
└── pom.xml
├── redis-storage
├── src
│ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── offbynull
│ │ │ └── actors
│ │ │ ├── redisclients
│ │ │ ├── jedis
│ │ │ │ ├── package-info.java
│ │ │ │ ├── JedisConnector.java
│ │ │ │ └── JedisPoolConnector.java
│ │ │ └── test
│ │ │ │ ├── package-info.java
│ │ │ │ ├── InternalList.java
│ │ │ │ ├── TestConnector.java
│ │ │ │ └── InternalSortedSet.java
│ │ │ ├── redisclient
│ │ │ ├── package-info.java
│ │ │ ├── WatchBlock.java
│ │ │ ├── TransactionBlock.java
│ │ │ ├── Connector.java
│ │ │ ├── SortedSetItem.java
│ │ │ ├── ConnectionException.java
│ │ │ ├── Transaction.java
│ │ │ ├── TransactionResult.java
│ │ │ └── Watch.java
│ │ │ └── gateways
│ │ │ ├── actor
│ │ │ └── stores
│ │ │ │ └── redis
│ │ │ │ ├── package-info.java
│ │ │ │ ├── ConversionUtils.java
│ │ │ │ └── QueueCountController.java
│ │ │ └── servlet
│ │ │ └── stores
│ │ │ └── redis
│ │ │ ├── package-info.java
│ │ │ ├── ConversionUtils.java
│ │ │ └── QueueDetails.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── offbynull
│ │ └── actors
│ │ ├── gateways
│ │ └── actor
│ │ │ ├── SerializableActorHelper.java
│ │ │ └── stores
│ │ │ └── redis
│ │ │ ├── TimestampQueueTest.java
│ │ │ └── ActorAccessorTest.java
│ │ └── ActorSystemTest.java
├── nb-configuration.xml
├── nbactions.xml
└── pom.xml
├── servlet-gateway
└── pom.xml
├── .gitignore
└── README.md
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/offbynull/actors/HEAD/logo.png
--------------------------------------------------------------------------------
/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CUSTOM-check_for_new_dependencies
5 | check_for_new_dependencies
6 | false
7 |
8 | versions:display-dependency-updates
9 |
10 |
11 |
12 | CUSTOM-check_for_new_plugins
13 | check_for_new_plugins
14 | false
15 |
16 | versions:display-plugin-updates
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/core/src/test/java/com/offbynull/actors/shuttles/blackhole/BlackholeShuttleTest.java:
--------------------------------------------------------------------------------
1 | package com.offbynull.actors.shuttles.blackhole;
2 |
3 | import com.offbynull.actors.shuttles.blackhole.BlackholeShuttle;
4 | import com.offbynull.actors.address.Address;
5 | import com.offbynull.actors.shuttle.Message;
6 | import java.util.Arrays;
7 | import org.junit.Before;
8 | import org.junit.Test;
9 |
10 | public class BlackholeShuttleTest {
11 |
12 | private BlackholeShuttle fixture;
13 |
14 | @Before
15 | public void setUp() {
16 | fixture = new BlackholeShuttle("test");
17 | }
18 |
19 | @Test
20 | public void mustNotCrash() {
21 | fixture.send(Arrays.asList(new Message(Address.fromString("src:fake1"), Address.fromString("test:sub1"), "hi1")));
22 | fixture.send(Arrays.asList(new Message(Address.fromString("src:fake2"), Address.fromString("fake"), "hi2")));
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/common/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Common utility and helper classes.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.common;
24 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Provides main classes and interfaces for actors core.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors;
24 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateways/actor/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Gateway that runs distributed actors.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.gateways.actor;
24 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateways/log/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Gateway that pipes log messages to SLF4J.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.gateways.log;
24 |
--------------------------------------------------------------------------------
/jdbc-storage/src/main/java/com/offbynull/actors/jdbcclient/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Provides classes and interfaces for JDBC access.
20 | * @author Kasra Faghihi
21 | */
22 | package com.offbynull.actors.jdbcclient;
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/redisclients/jedis/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Redis connector that uses Jedis.
20 | * @author Kasra Faghihi
21 | */
22 | package com.offbynull.actors.redisclients.jedis;
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/address/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Provides classes and interfaces for defining addresses.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.address;
24 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateway/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Provides classes and interfaces for defining gateways.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.gateway;
24 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/shuttle/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Provides classes and interfaces for defining shuttles.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.shuttle;
24 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/shuttles/blackhole/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Shuttle implementation that throws away all messages.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.shuttles.blackhole;
24 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/redisclient/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Provides classes and interfaces for defining low-level Redis connectors.
20 | * @author Kasra Faghihi
21 | */
22 | package com.offbynull.actors.redisclient;
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateways/servlet/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Gateway that allows HTTP clients to send and receive messages.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.gateways.servlet;
24 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/shuttles/simple/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * A shuttle implementation that sends messages to a local bus.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.shuttles.simple;
24 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateways/threadpool/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Gateway that pipes messages to a thread pool for processing.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.gateways.threadpool;
24 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateways/actor/stores/memory/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * In-memory actor storage engine implementation.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.gateways.actor.stores.memory;
24 |
--------------------------------------------------------------------------------
/jdbc-storage/src/main/java/com/offbynull/actors/gateways/actor/stores/jdbc/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * JDBC actor storage engine implementation.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.gateways.actor.stores.jdbc;
24 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateways/servlet/stores/memory/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * In-memory servlet storage engine implementation.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.gateways.servlet.stores.memory;
24 |
--------------------------------------------------------------------------------
/jdbc-storage/src/main/java/com/offbynull/actors/gateways/servlet/stores/jdbc/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * JDBC servlet storage engine implementation.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.gateways.servlet.stores.jdbc;
24 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/gateways/actor/stores/redis/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Redis actor storage engine implementation.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.gateways.actor.stores.redis;
24 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateways/timer/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Gateway that accepts a message and echoes it back after a certain duration of time.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.gateways.timer;
24 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/gateways/servlet/stores/redis/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Redis servlet storage engine implementation.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.gateways.servlet.stores.redis;
24 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateways/direct/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Gateway that allows normal Java code to send messages to and receive messages to gateways.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.gateways.direct;
24 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/shuttles/pump/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * A shuttle implementation that queues up and pumps messages into a potentially slower shuttle.
20 | *
21 | * @author Kasra Faghihi
22 | */
23 | package com.offbynull.actors.shuttles.pump;
24 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/redisclients/test/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 |
18 | /**
19 | * Redis connector that mocks a local Redis server. This is mainly used for testing higher-level classes.
20 | * @author Kasra Faghihi
21 | */
22 | package com.offbynull.actors.redisclients.test;
--------------------------------------------------------------------------------
/core/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 | none
17 |
18 |
19 |
--------------------------------------------------------------------------------
/jdbc-storage/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 | none
17 |
18 |
19 |
--------------------------------------------------------------------------------
/redis-storage/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 | none
17 |
18 |
19 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateways/actor/FailListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.gateways.actor;
18 |
19 | /**
20 | * Listens for shutdowns in {@link ActorGateway} threads.
21 | * @author Kasra Faghihi
22 | */
23 | public interface FailListener {
24 | /**
25 | * A {@link ActorGateway} thread has encountered a problem and has to shutdown.
26 | * @param t throwable that caused the error
27 | */
28 | void failed(Throwable t);
29 | }
30 |
--------------------------------------------------------------------------------
/core/src/test/java/com/offbynull/actors/gateways/actor/SerializableActorHelper.java:
--------------------------------------------------------------------------------
1 | package com.offbynull.actors.gateways.actor;
2 |
3 | import com.offbynull.actors.address.Address;
4 | import com.offbynull.coroutines.user.CoroutineRunner;
5 |
6 | public final class SerializableActorHelper {
7 | private SerializableActorHelper() {
8 | // do nothing
9 | }
10 |
11 | public static SerializableActor createFake(String address) {
12 | Context context = new Context(Address.fromString(address));
13 | CoroutineRunner runner = new CoroutineRunner(cnt -> {});
14 | Actor actor = new Actor(null, runner, context);
15 |
16 | return SerializableActor.serialize(actor);
17 | }
18 |
19 | public static SerializableActor createFake(String address, Object checkpointMsg, long checkpointTimeout) {
20 | Context context = new Context(Address.fromString(address));
21 | context.checkpointTimeout(checkpointTimeout);
22 | context.checkpointPayload(checkpointMsg);
23 | CoroutineRunner runner = new CoroutineRunner(cnt -> {});
24 | Actor actor = new Actor(null, runner, context);
25 |
26 | return SerializableActor.serialize(actor);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/jdbc-storage/src/test/java/com/offbynull/actors/gateways/actor/SerializableActorHelper.java:
--------------------------------------------------------------------------------
1 | package com.offbynull.actors.gateways.actor;
2 |
3 | import com.offbynull.actors.address.Address;
4 | import com.offbynull.coroutines.user.CoroutineRunner;
5 |
6 | public final class SerializableActorHelper {
7 | private SerializableActorHelper() {
8 | // do nothing
9 | }
10 |
11 | public static SerializableActor createFake(String address) {
12 | Context context = new Context(Address.fromString(address));
13 | CoroutineRunner runner = new CoroutineRunner(cnt -> {});
14 | Actor actor = new Actor(null, runner, context);
15 |
16 | return SerializableActor.serialize(actor);
17 | }
18 |
19 | public static SerializableActor createFake(String address, Object checkpointMsg, long checkpointTimeout) {
20 | Context context = new Context(Address.fromString(address));
21 | context.checkpointTimeout(checkpointTimeout);
22 | context.checkpointPayload(checkpointMsg);
23 | CoroutineRunner runner = new CoroutineRunner(cnt -> {});
24 | Actor actor = new Actor(null, runner, context);
25 |
26 | return SerializableActor.serialize(actor);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/gateways/servlet/stores/redis/ConversionUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.gateways.servlet.stores.redis;
18 |
19 | import static java.nio.charset.StandardCharsets.UTF_8;
20 |
21 | final class ConversionUtils {
22 |
23 | private ConversionUtils() {
24 | // do nothing
25 | }
26 |
27 | static Integer stringToInt(byte[] data) {
28 | return data == null ? null : Integer.valueOf(new String(data, UTF_8));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/redis-storage/src/test/java/com/offbynull/actors/gateways/actor/SerializableActorHelper.java:
--------------------------------------------------------------------------------
1 | package com.offbynull.actors.gateways.actor;
2 |
3 | import com.offbynull.actors.address.Address;
4 | import com.offbynull.coroutines.user.CoroutineRunner;
5 |
6 | public final class SerializableActorHelper {
7 | private SerializableActorHelper() {
8 | // do nothing
9 | }
10 |
11 | public static SerializableActor createFake(String address) {
12 | Context context = new Context(Address.fromString(address));
13 | CoroutineRunner runner = new CoroutineRunner(cnt -> {});
14 | Actor actor = new Actor(null, runner, context);
15 |
16 | return SerializableActor.serialize(actor);
17 | }
18 |
19 | public static SerializableActor createFake(String address, Object checkpointMsg, long checkpointTimeout) {
20 | Context context = new Context(Address.fromString(address));
21 | context.checkpointTimeout(checkpointTimeout);
22 | context.checkpointPayload(checkpointMsg);
23 | CoroutineRunner runner = new CoroutineRunner(cnt -> {});
24 | Actor actor = new Actor(null, runner, context);
25 |
26 | return SerializableActor.serialize(actor);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateways/timer/RemoveShuttle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.gateways.timer;
18 |
19 | import org.apache.commons.lang3.Validate;
20 |
21 | final class RemoveShuttle {
22 | private final String prefix;
23 |
24 | RemoveShuttle(String prefix) {
25 | Validate.notNull(prefix);
26 | this.prefix = prefix;
27 | }
28 |
29 | public String getPrefix() {
30 | return prefix;
31 | }
32 |
33 | @Override
34 | public String toString() {
35 | return "RemoveShuttle{" + "prefix=" + prefix + '}';
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/redisclient/WatchBlock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.redisclient;
18 |
19 | /**
20 | * Block that defines watch conditions.
21 | * @author Kasra Faghihi
22 | */
23 | public interface WatchBlock {
24 | /**
25 | * Performs Redis operations to check that certain conditions are met.
26 | * @return if conditions were met
27 | * @throws ConnectionException if there was a problem with redis or the connection to redis
28 | * @throws IllegalStateException if connector closed
29 | */
30 | boolean execute() throws ConnectionException;
31 | }
32 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateways/timer/AddShuttle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.gateways.timer;
18 |
19 | import com.offbynull.actors.shuttle.Shuttle;
20 | import org.apache.commons.lang3.Validate;
21 |
22 | final class AddShuttle {
23 | private final Shuttle shuttle;
24 |
25 | AddShuttle(Shuttle shuttle) {
26 | Validate.notNull(shuttle);
27 | this.shuttle = shuttle;
28 | }
29 |
30 | public Shuttle getShuttle() {
31 | return shuttle;
32 | }
33 |
34 | @Override
35 | public String toString() {
36 | return "AddShuttle{" + "shuttle=" + shuttle + '}';
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/redisclient/TransactionBlock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.redisclient;
18 |
19 | /**
20 | * Redis operations to perform inside a MULTI/EXEC block.
21 | * @author Kasra Faghihi
22 | */
23 | public interface TransactionBlock {
24 | /**
25 | * Queues Redis operations to perform in a MULTI/EXEC block.
26 | * @param queue transaction queue
27 | * @throws ConnectionException if there was a problem with redis or the connection to redis
28 | * @throws NullPointerException if any argument is {@code null}
29 | * @throws IllegalStateException if connector closed
30 | */
31 | void execute(TransactionQueue queue) throws ConnectionException;
32 | }
33 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/redisclient/Connector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.redisclient;
18 |
19 | import java.io.Closeable;
20 |
21 | /**
22 | * A low-level Redis connector.
23 | *
24 | * Implementations may or may not be bound to to this connector. That means that if this {@link Connector} is closed, the generated
25 | * {@link Connection}s is may also be closed.
26 | *
27 | * Implementations must be thread-safe.
28 | * @author Kasra Faghihi
29 | */
30 | public interface Connector extends Closeable {
31 | /**
32 | * Get a {@link Connection}.
33 | * @return connection
34 | * @throws IllegalStateException if closed
35 | */
36 | Connection getConnection();
37 | }
38 |
--------------------------------------------------------------------------------
/core/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | test
5 |
6 | *
7 |
8 |
9 | test
10 | coroutines:test-instrument
11 |
12 |
13 |
14 | test.single
15 |
16 | *
17 |
18 |
19 | test-compile
20 | coroutines:test-instrument
21 | surefire:test
22 |
23 |
24 | ${packageClassName}
25 |
26 |
27 |
28 | debug.test.single
29 |
30 | *
31 |
32 |
33 | test-compile
34 | coroutines:test-instrument
35 | surefire:test
36 |
37 |
38 | ${packageClassName}
39 | once
40 | -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}
41 | true
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/gateways/actor/stores/redis/ConversionUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.gateways.actor.stores.redis;
18 |
19 | import static java.nio.charset.StandardCharsets.UTF_8;
20 |
21 | final class ConversionUtils {
22 |
23 | private ConversionUtils() {
24 | // do nothing
25 | }
26 |
27 | static String byteArrayToString(byte[] data) {
28 | return data == null ? null : new String(data, UTF_8);
29 | }
30 |
31 | static Integer stringToInt(byte[] data) {
32 | return data == null ? null : Integer.valueOf(new String(data, UTF_8));
33 | }
34 |
35 | static Long stringToLong(byte[] data) {
36 | return data == null ? null : Long.valueOf(new String(data, UTF_8));
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/jdbc-storage/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | test
5 |
6 | *
7 |
8 |
9 | test
10 | coroutines:test-instrument
11 |
12 |
13 |
14 | test.single
15 |
16 | *
17 |
18 |
19 | test-compile
20 | coroutines:test-instrument
21 | surefire:test
22 |
23 |
24 | ${packageClassName}
25 |
26 |
27 |
28 | debug.test.single
29 |
30 | *
31 |
32 |
33 | test-compile
34 | coroutines:test-instrument
35 | surefire:test
36 |
37 |
38 | ${packageClassName}
39 | once
40 | -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}
41 | true
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/redis-storage/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | test
5 |
6 | *
7 |
8 |
9 | test
10 | coroutines:test-instrument
11 |
12 |
13 |
14 | test.single
15 |
16 | *
17 |
18 |
19 | test-compile
20 | coroutines:test-instrument
21 | surefire:test
22 |
23 |
24 | ${packageClassName}
25 |
26 |
27 |
28 | debug.test.single
29 |
30 | *
31 |
32 |
33 | test-compile
34 | coroutines:test-instrument
35 | surefire:test
36 |
37 |
38 | ${packageClassName}
39 | once
40 | -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}
41 | true
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/servlet-gateway/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | com.offbynull.actors
6 | parent
7 | 1.0.0-SNAPSHOT
8 |
9 | servlet-gateway
10 | jar
11 |
12 | ${project.groupId}:${project.artifactId}
13 |
14 |
15 | ${project.groupId}
16 | core
17 | ${project.version}
18 |
19 |
20 | com.google.code.gson
21 | gson
22 | 2.8.0
23 |
24 |
25 | javax.servlet
26 | javax.servlet-api
27 | 3.1.0
28 | jar
29 |
30 |
31 | junit
32 | junit
33 |
34 |
35 | org.mockito
36 | mockito-all
37 |
38 |
39 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateways/servlet/ResponseBlock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.gateways.servlet;
18 |
19 | import com.offbynull.actors.shuttle.Message;
20 | import java.util.ArrayList;
21 | import java.util.List;
22 | import org.apache.commons.collections4.list.UnmodifiableList;
23 | import static org.apache.commons.collections4.list.UnmodifiableList.unmodifiableList;
24 | import org.apache.commons.lang3.Validate;
25 |
26 | final class ResponseBlock {
27 | private final UnmodifiableList outQueue;
28 |
29 | ResponseBlock(List outQueue) {
30 | Validate.notNull(outQueue);
31 | Validate.noNullElements(outQueue);
32 | this.outQueue = (UnmodifiableList) unmodifiableList(new ArrayList<>(outQueue));
33 | }
34 |
35 | public UnmodifiableList getOutQueue() {
36 | return outQueue;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/core/src/test/java/com/offbynull/actors/gateways/log/LogGatewayTest.java:
--------------------------------------------------------------------------------
1 | package com.offbynull.actors.gateways.log;
2 |
3 | import com.offbynull.actors.gateways.direct.DirectGateway;
4 | import org.apache.commons.io.IOUtils;
5 | import org.junit.After;
6 | import org.junit.Before;
7 | import org.junit.Test;
8 |
9 | public class LogGatewayTest {
10 |
11 | private DirectGateway directGateway;
12 | private LogGateway logGateway;
13 |
14 | @Before
15 | public void before() {
16 | directGateway = DirectGateway.create("direct");
17 | logGateway = LogGateway.create("log");
18 |
19 | directGateway.addOutgoingShuttle(logGateway.getIncomingShuttle());
20 | logGateway.addOutgoingShuttle(directGateway.getIncomingShuttle());
21 | }
22 |
23 | @After
24 | public void after() {
25 | IOUtils.closeQuietly(directGateway);
26 | IOUtils.closeQuietly(logGateway);
27 | }
28 |
29 | // This is difficult to test because its piping to SLF4J, but we can atleast add in a sanity test here
30 | @Test
31 | public void mustNotCrash() throws InterruptedException {
32 | // Remember that since these gateways running in different threads, tehy can close before the log gateway gets all 4 messages
33 | directGateway.writeMessage("direct", "log", LogMessage.error("log msg!!!! {}", 1));
34 | directGateway.writeMessage("direct", "log", LogMessage.error("log msg!!!! {}", 2));
35 | directGateway.writeMessage("direct", "log", LogMessage.error("log msg!!!! {}", 3));
36 | directGateway.writeMessage("direct", "log", LogMessage.error("log msg!!!! {}", 4));
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/core/src/test/java/com/offbynull/actors/ActorSystemTest.java:
--------------------------------------------------------------------------------
1 | package com.offbynull.actors;
2 |
3 | import com.offbynull.actors.gateways.actor.Context;
4 | import com.offbynull.coroutines.user.Coroutine;
5 | import static org.junit.Assert.assertEquals;
6 | import org.junit.Test;
7 |
8 | public class ActorSystemTest {
9 |
10 | @Test(timeout = 2000L)
11 | public void mustCreateAndCommunicateActorsAndGateways() throws Exception {
12 | Coroutine echoer = cnt -> {
13 | Context ctx = (Context) cnt.getContext();
14 | ctx.allow();
15 |
16 | cnt.suspend();
17 |
18 | ctx.out("actor:sender", ctx.in());
19 | };
20 |
21 | Coroutine sender = cnt -> {
22 | Context ctx = (Context) cnt.getContext();
23 | ctx.allow();
24 |
25 | // Send a message to echoer
26 | ctx.out("actor:echoer", "hi");
27 | cnt.suspend();
28 |
29 | // Forward the response we got to the direct gateway
30 | String response = ctx.in();
31 | ctx.out("direct:test", response);
32 | };
33 |
34 | try (ActorSystem actorSystem = ActorSystem.createDefault()) {
35 | actorSystem.getDirectGateway().listen("direct:test");
36 |
37 | actorSystem.getActorGateway().addActor("echoer", echoer, new Object());
38 | actorSystem.getActorGateway().addActor("sender", sender, new Object());
39 |
40 | String output = actorSystem.getDirectGateway().readMessagePayloadOnly("direct:test");
41 |
42 | assertEquals("hi", output);
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /eventframework/target/
2 | /chord/target/
3 | /communication-helper/target/
4 | /eventframework-core/target/
5 | /eventframework-network/target/
6 | /eventframework/eventframework-basic/target/
7 | /eventframework/eventframework-core/target/
8 | /eventframework/eventframework/target/
9 | /p2p-tools/target/
10 | /bin-tools/target/
11 | /basic-chord/target/
12 | /p2p-rpc/target/
13 | /rpc/target/
14 | /rpc-common/target/
15 | /target/
16 | /overlay-unstructured/target/
17 | /overlay-visualizer/target/
18 | /demo/target/
19 | /build-tools/target/
20 | /visualizer/target/
21 | /overlay-gui-visualizer/target/
22 | /overlay-common/target/
23 | /overlay-chord/target/
24 | /rpc-transport/target/
25 | /rpc-invoke/target/
26 | /common/target/
27 | /actor/target/
28 | /actor-network/target/
29 | /nat/target/
30 | /router-natpmp/target/
31 | /portmapper/target/
32 | /netty-simulation/target/
33 | /netty-p2p/target/
34 | /network/target/
35 | /netty-helper/target/
36 | /network-tools/target/
37 | /netty-extensions/target/
38 | /core/target/
39 | /debug/target/
40 | /playground/unstructured-mesh/target/
41 | /playground/unstructured-mesh/target2/
42 | /playground/unstructured-mesh/target2222/
43 | /playground/unstructured-mesh/target123123123/
44 | /playground/unstructured-mesh/targetaaaaaaa/
45 | /playground/unstructured-mesh/targetssssssssssssss/
46 | /playground/chord-dht/target/
47 | /unstructured-mesh/target/
48 | /examples/target/
49 | /io/target/
50 | /core/nbproject/
51 | /redis-storage/target/
52 | /redis-storage/nbproject/
53 | /jdbc-storage/target/
54 | /jdbc-storage/derby.log
55 | /servlet-gateway/target/
56 | /servlet-gateway/nbproject/
57 | /redis-storage/nbproject/
58 | /redis-storage/target/
59 | /jdbc-storage/target/
60 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/gateways/threadpool/ThreadPoolProcessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.gateways.threadpool;
18 |
19 | import com.offbynull.actors.shuttle.Message;
20 | import com.offbynull.actors.shuttle.Shuttle;
21 | import java.util.concurrent.ConcurrentHashMap;
22 |
23 | /**
24 | * Processes a {@link ThreadPoolGateway}'s incoming messages. Incoming messages are processed in the gateway's thread pool.
25 | * @author Kasra Faghihi
26 | */
27 | public interface ThreadPoolProcessor {
28 | /**
29 | * Process incoming message.
30 | * @param message message to be processed
31 | * @param outShuttles shuttles that can be be output to (DO NOT MODIFY)
32 | * @throws Exception on error
33 | * @throws NullPointerException if any argument is {@code null}
34 | */
35 | void process(Message message, ConcurrentHashMap outShuttles) throws Exception;
36 | // outShuttles is concurrent map -- entries added/removed on the fly, don't nullcheck keys or values
37 | }
38 |
--------------------------------------------------------------------------------
/core/src/test/java/com/offbynull/actors/gateways/timer/TimerGatewayTest.java:
--------------------------------------------------------------------------------
1 | package com.offbynull.actors.gateways.timer;
2 |
3 | import com.offbynull.actors.gateways.direct.DirectGateway;
4 | import com.offbynull.actors.shuttle.Message;
5 | import java.util.concurrent.TimeUnit;
6 | import org.apache.commons.io.IOUtils;
7 | import org.junit.After;
8 | import static org.junit.Assert.assertEquals;
9 | import org.junit.Before;
10 | import org.junit.Test;
11 |
12 | public class TimerGatewayTest {
13 |
14 | private DirectGateway directGateway;
15 | private TimerGateway timerGateway;
16 |
17 | @Before
18 | public void before() {
19 | directGateway = DirectGateway.create("direct");
20 | timerGateway = TimerGateway.create("timer");
21 |
22 | directGateway.addOutgoingShuttle(timerGateway.getIncomingShuttle());
23 | timerGateway.addOutgoingShuttle(directGateway.getIncomingShuttle());
24 | }
25 |
26 | @After
27 | public void after() {
28 | IOUtils.closeQuietly(directGateway);
29 | IOUtils.closeQuietly(timerGateway);
30 | }
31 |
32 | @Test
33 | public void mustEchoBackMessageAfter500Milliseconds() throws Exception {
34 | directGateway.listen("direct:tester");
35 |
36 | directGateway.writeMessage("direct:tester:inner1:inner2", "timer:500:inner3:inner4", "payload");
37 | Message echoed = directGateway.readMessage("direct:tester", 500 + 250 /* 250ms of padding */, TimeUnit.MILLISECONDS);
38 |
39 | assertEquals("timer:500:inner3:inner4", echoed.getSourceAddress().toString());
40 | assertEquals("direct:tester:inner1:inner2", echoed.getDestinationAddress().toString());
41 | assertEquals("payload", echoed.getMessage());
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/redisclient/SortedSetItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.redisclient;
18 |
19 | /**
20 | * Item for a Redis sorted set (score and item).
21 | * @author Kasra Faghihi
22 | */
23 | public final class SortedSetItem {
24 |
25 | private final double score;
26 | private final Object item;
27 |
28 | /**
29 | * Constructs a {@link SortedSetItem} object.
30 | * @param score score
31 | * @param item item
32 | */
33 | public SortedSetItem(double score, Object item) {
34 | this.score = score;
35 | this.item = item;
36 | }
37 |
38 | /**
39 | * Get score.
40 | * @return score
41 | */
42 | public double getScore() {
43 | return score;
44 | }
45 |
46 | /**
47 | * Get item.
48 | * @param expected type
49 | * @return item
50 | * @throws ClassCastException if expected type is not the type stored
51 | */
52 | public T getItem() {
53 | return (T) item;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/redisclient/ConnectionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.redisclient;
18 |
19 | /**
20 | * A low-level Redis connection exception.
21 | * @author Kasra Faghihi
22 | */
23 | public final class ConnectionException extends Exception {
24 | private static final long serialVersionUID = 1L;
25 |
26 | private final boolean connectionProblem;
27 |
28 | /**
29 | * Constructs a {@link ConnectionException} object.
30 | * @param connectionProblem {@code true} if this exception was caused by connection issues, {@code false} otherwise
31 | * @param cause cause of this exception
32 | */
33 | public ConnectionException(boolean connectionProblem, Throwable cause) {
34 | super(cause);
35 | this.connectionProblem = connectionProblem;
36 | }
37 |
38 | /**
39 | * Gets the connection problem flag.
40 | * @return {@code true} if this exception was caused by connection issues
41 | */
42 | public boolean isConnectionProblem() {
43 | return connectionProblem;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/core/src/test/java/com/offbynull/actors/gateways/actor/ActorNeighbourSpawnTest.java:
--------------------------------------------------------------------------------
1 |
2 | package com.offbynull.actors.gateways.actor;
3 |
4 | import com.offbynull.actors.gateways.direct.DirectGateway;
5 | import com.offbynull.coroutines.user.Coroutine;
6 | import org.junit.After;
7 | import static org.junit.Assert.assertEquals;
8 | import org.junit.Test;
9 | import org.junit.Before;
10 |
11 | public class ActorNeighbourSpawnTest {
12 |
13 | private ActorGateway runner;
14 | private DirectGateway direct;
15 |
16 | @Before
17 | public void setUp() {
18 | runner = ActorGateway.create("runner", 1);
19 | direct = DirectGateway.create("direct");
20 |
21 | direct.addOutgoingShuttle(runner.getIncomingShuttle());
22 | runner.addOutgoingShuttle(direct.getIncomingShuttle());
23 |
24 | direct.listen("direct");
25 | }
26 |
27 | @After
28 | public void tearDown() throws Exception {
29 | runner.close();
30 | direct.close();
31 | }
32 |
33 | @Test(timeout = 2000L)
34 | public void mustSpawnRootActorFromAnotherRootActor() throws Exception {
35 | Coroutine actor1 = cnt -> {
36 | Context ctx = (Context) cnt.getContext();
37 | ctx.allow();
38 |
39 | ctx.out("direct", "ready from 1");
40 | };
41 |
42 | Coroutine actor0 = cnt -> {
43 | Context ctx = (Context) cnt.getContext();
44 | ctx.allow();
45 | ctx.out("direct", "ready from 0");
46 |
47 | ctx.root("actor1", actor1, new Object());
48 | };
49 |
50 | runner.addActor("actor0", actor0, new Object());
51 |
52 |
53 | assertEquals("ready from 0", direct.readMessagePayloadOnly("direct"));
54 | assertEquals("ready from 1", direct.readMessagePayloadOnly("direct"));
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/redisclients/test/InternalList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.redisclients.test;
18 |
19 | import java.util.LinkedList;
20 | import java.util.List;
21 |
22 | final class InternalList {
23 | private final LinkedList items = new LinkedList<>();
24 |
25 | byte[] rpop() {
26 | return items.removeLast();
27 | }
28 |
29 | byte[] lpop() {
30 | return items.removeFirst();
31 | }
32 |
33 | void rpush(byte[] e) {
34 | items.addLast(e);
35 | }
36 |
37 | void lpush(byte[] e) {
38 | items.addFirst(e);
39 | }
40 |
41 | List lrange(int start, int end) {
42 | int revisedStart = start;
43 | if (revisedStart >= items.size()) {
44 | revisedStart = items.size() - 1;
45 | }
46 |
47 | int revisedEnd = end;
48 | if (revisedEnd >= items.size()) {
49 | revisedEnd = items.size() - 1;
50 | }
51 |
52 | return new LinkedList<>(items.subList(revisedStart, revisedEnd + 1));
53 | }
54 |
55 | int size() {
56 | return items.size();
57 | }
58 |
59 | boolean isEmpty() {
60 | return items.isEmpty();
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/redis-storage/src/test/java/com/offbynull/actors/gateways/actor/stores/redis/TimestampQueueTest.java:
--------------------------------------------------------------------------------
1 | package com.offbynull.actors.gateways.actor.stores.redis;
2 |
3 | import com.offbynull.actors.redisclient.Connection;
4 | import static com.offbynull.actors.address.Address.fromString;
5 | import com.offbynull.actors.redisclient.Connector;
6 | import com.offbynull.actors.redisclients.test.TestConnector;
7 | import org.junit.After;
8 | import static org.junit.Assert.assertArrayEquals;
9 | import static org.junit.Assert.assertEquals;
10 | import static org.junit.Assert.assertNull;
11 | import org.junit.Before;
12 | import org.junit.Test;
13 |
14 | public final class TimestampQueueTest {
15 |
16 | private Connector connector;
17 | private Connection connection;
18 |
19 |
20 | @Before
21 | public void setUp() throws Exception {
22 | // connector = new JedisPoolConnector("192.168.56.101", 6379, 1);
23 | // clientFactory = new ConnectorClientFactory(connector);
24 | connector = new TestConnector();
25 | connection = connector.getConnection();
26 | }
27 |
28 | @After
29 | public void tearDown() throws Exception {
30 | connection.close();
31 | connector.close();
32 | }
33 |
34 | @Test
35 | public void mustProperlyPullFromTimestampQueue() throws Exception {
36 | TimestampQueue rtq = new TimestampQueue(connection, "test", 1);
37 |
38 | rtq.insert(0, fromString("test1:test2:a"));
39 | rtq.insert(5, fromString("test1:test2:d"));
40 | rtq.insert(2, fromString("test1:test2:c"));
41 | rtq.insert(1, fromString("test1:test2:b"));
42 |
43 | assertEquals(fromString("test1:test2:a"), rtq.remove(10L));
44 | assertEquals(fromString("test1:test2:b"), rtq.remove(10L));
45 | assertEquals(fromString("test1:test2:c"), rtq.remove(10L));
46 | assertEquals(fromString("test1:test2:d"), rtq.remove(10L));
47 | assertNull(rtq.remove(10L));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/redisclient/Transaction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.redisclient;
18 |
19 | import org.apache.commons.lang3.Validate;
20 |
21 | /**
22 | * Redis MULTI/EXEC transaction operation.
23 | * @author Kasra Faghihi
24 | */
25 | public final class Transaction {
26 |
27 | private final TransactionBlock block;
28 | private final boolean retry;
29 |
30 | /**
31 | * Constructs a {@link Transaction} object.
32 | * @param retry if {@code true}, transaction will be retried until it passes
33 | * @param block block that defines queued transaction operations
34 | * @throws NullPointerException if any argument is {@code null}
35 | */
36 | public Transaction(boolean retry, TransactionBlock block) {
37 | Validate.notNull(block);
38 | this.retry = retry;
39 | this.block = block;
40 | }
41 |
42 | /**
43 | * Get retry flag.
44 | * @return if {@code true}, transaction will be retried until it passes
45 | */
46 | public boolean isRetry() {
47 | return retry;
48 | }
49 |
50 | /**
51 | * Get transaction block.
52 | * @return block that defines queued transaction operations
53 | */
54 | public TransactionBlock getBlock() {
55 | return block;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/redisclients/test/TestConnector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.redisclients.test;
18 |
19 | import com.offbynull.actors.redisclient.Connection;
20 | import com.offbynull.actors.redisclient.Connector;
21 | import com.offbynull.actors.redisclients.test.TestConnection.Item;
22 | import java.io.IOException;
23 | import java.util.HashMap;
24 | import java.util.Map;
25 | import java.util.concurrent.atomic.AtomicBoolean;
26 | import org.apache.commons.lang3.Validate;
27 |
28 | /**
29 | * Test connector. This class is thread-safe.
30 | *
31 | * All {@link Connection} objects derived from this {@link Connector} point to the same database. If this {@link Connector} is closed, any
32 | * generated {@link Connection}s are also closed.
33 | * @author Kasra Faghihi
34 | */
35 | public final class TestConnector implements Connector {
36 |
37 | private final Map keyspace = new HashMap<>();
38 | private final AtomicBoolean closed = new AtomicBoolean();
39 |
40 | @Override
41 | public Connection getConnection() {
42 | Validate.validState(!closed.get(), "Closed");
43 | return new TestConnection(keyspace, closed);
44 | }
45 |
46 | @Override
47 | public void close() throws IOException {
48 | closed.set(true);
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/gateways/actor/stores/redis/QueueCountController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.gateways.actor.stores.redis;
18 |
19 | import org.apache.commons.lang3.Validate;
20 |
21 | /**
22 | * Controls the number of timestamp queues. This count can be modified even after being passed into {@link RedisStore}.
23 | *
24 | * Increase to spread load over multiple queues in times of high-load, then decrease to reduce the number of queues back down.
25 | * @author Kasra Faghihi
26 | */
27 | public final class QueueCountController {
28 |
29 | private volatile int count;
30 |
31 | /**
32 | * Constructs a {@link QueueCountController} object.
33 | * @param count initial number of queues
34 | * @throws IllegalArgumentException if {@code count <= 0}
35 | */
36 | public QueueCountController(int count) {
37 | Validate.isTrue(count >= 1);
38 | this.count = count;
39 | }
40 |
41 | /**
42 | * Get queue count.
43 | * @return queue count
44 | */
45 | public int getCount() {
46 | return count;
47 | }
48 |
49 | /**
50 | * Set queue count.
51 | * @param count queue count
52 | * @throws IllegalArgumentException if {@code count <= 0}
53 | */
54 | public void setCount(int count) {
55 | Validate.isTrue(count >= 1);
56 | this.count = count;
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/core/src/main/java/com/offbynull/actors/shuttles/blackhole/BlackholeShuttle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.shuttles.blackhole;
18 |
19 | import com.offbynull.actors.shuttle.Message;
20 | import com.offbynull.actors.shuttle.Shuttle;
21 | import java.util.Collection;
22 | import org.apache.commons.lang3.Validate;
23 | import org.slf4j.Logger;
24 | import org.slf4j.LoggerFactory;
25 |
26 | /**
27 | * A shuttle implementation that discards all messages sent to it.
28 | * @author Kasra Faghihi
29 | */
30 | public final class BlackholeShuttle implements Shuttle {
31 |
32 | private static final Logger LOG = LoggerFactory.getLogger(BlackholeShuttle.class);
33 | private final String prefix;
34 |
35 | /**
36 | * Constructs a {@link BlackholeShuttle} instance.
37 | * @param prefix address prefix of this shuttle
38 | * @throws NullPointerException if any argument is {@code null}
39 | */
40 | public BlackholeShuttle(String prefix) {
41 | Validate.notNull(prefix);
42 | this.prefix = prefix;
43 | }
44 |
45 | @Override
46 | public String getPrefix() {
47 | return prefix;
48 | }
49 |
50 | @Override
51 | public void send(Collection messages) {
52 | Validate.notNull(messages);
53 | Validate.noNullElements(messages);
54 | // do nothing
55 |
56 | LOG.debug("Received {} messages", messages.size());
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/jdbc-storage/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | com.offbynull.actors
6 | parent
7 | 1.0.0-SNAPSHOT
8 |
9 | jdbc-storage
10 | jar
11 |
12 | ${project.groupId}:${project.artifactId}
13 |
14 |
15 | ${project.groupId}
16 | core
17 | ${project.version}
18 |
19 |
20 |
21 | junit
22 | junit
23 |
24 |
25 | org.slf4j
26 | slf4j-simple
27 | test
28 |
29 |
30 | org.apache.derby
31 | derby
32 | test
33 |
34 |
35 |
36 |
37 |
38 | org.apache.maven.plugins
39 | maven-checkstyle-plugin
40 |
41 |
42 | org.apache.maven.plugins
43 | maven-pmd-plugin
44 |
45 |
46 | com.github.spotbugs
47 | spotbugs-maven-plugin
48 |
49 |
50 | com.offbynull.coroutines
51 | maven-plugin
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/redis-storage/src/main/java/com/offbynull/actors/redisclient/TransactionResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, Kasra Faghihi, All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 3.0 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library.
16 | */
17 | package com.offbynull.actors.redisclient;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 | import org.apache.commons.lang3.Validate;
22 |
23 | /**
24 | * Results for each operation performed on a {@link TransactionQueue}.
25 | * @author Kasra Faghihi
26 | */
27 | public final class TransactionResult {
28 | private final List