From 5b4933f12a3eadedf84e6adf00e1c1ac15924f6d Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 8 Oct 2013 21:22:43 +0000 Subject: - identity service implemented - started with arm implementation - removed locking from scheduler - separated TaskConfiguration and TaskIdentifier - implemented proper message stream tokenizer - work on voting --- src/main/java/org/gnunet/arm/Arm.java | 70 ++++++++++++++++++++++ src/main/java/org/gnunet/arm/ArmMonitor.java | 27 +++++++++ src/main/java/org/gnunet/arm/ResultHandler.java | 31 ++++++++++ .../java/org/gnunet/arm/ServiceListHandler.java | 28 +++++++++ .../java/org/gnunet/arm/ServiceStatusHandler.java | 25 ++++++++ .../org/gnunet/arm/messages/ListResultMessage.java | 41 +++++++++++++ .../org/gnunet/arm/messages/RequestMessage.java | 25 ++++++++ .../org/gnunet/arm/messages/ResultMessage.java | 35 +++++++++++ .../org/gnunet/arm/messages/StatusMessage.java | 61 +++++++++++++++++++ 9 files changed, 343 insertions(+) create mode 100644 src/main/java/org/gnunet/arm/Arm.java create mode 100644 src/main/java/org/gnunet/arm/ArmMonitor.java create mode 100644 src/main/java/org/gnunet/arm/ResultHandler.java create mode 100644 src/main/java/org/gnunet/arm/ServiceListHandler.java create mode 100644 src/main/java/org/gnunet/arm/ServiceStatusHandler.java create mode 100644 src/main/java/org/gnunet/arm/messages/ListResultMessage.java create mode 100644 src/main/java/org/gnunet/arm/messages/RequestMessage.java create mode 100644 src/main/java/org/gnunet/arm/messages/ResultMessage.java create mode 100644 src/main/java/org/gnunet/arm/messages/StatusMessage.java (limited to 'src/main/java/org/gnunet/arm') diff --git a/src/main/java/org/gnunet/arm/Arm.java b/src/main/java/org/gnunet/arm/Arm.java new file mode 100644 index 0000000..503413f --- /dev/null +++ b/src/main/java/org/gnunet/arm/Arm.java @@ -0,0 +1,70 @@ +/* + This file is part of GNUnet. + (C) 2012, 2013 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.arm; + +import org.gnunet.util.Client; +import org.gnunet.util.Configuration; + +/** + * API for the Automatic Restart Manager (ARM) + */ +public class Arm { + private final Configuration configuration; + private Client client; + public Arm(Configuration configuration) { + this.configuration = configuration; + client = new Client("arm", configuration); + } + + /** + * Disconnect from ARM, the Arm object may not be used afterwards. + */ + public void disconnect() { + client.disconnect(); + } + public void requestServiceList(ServiceListHandler serviceListHandler) { + + } + + /** + * Request a service to be stopped. + * Stopping arm itself will not invalidate its handle, and + * ARM API will try to restore connection to the ARM service, + * even if ARM connection was lost because you asked for ARM to be stopped. + * Call Arm.disconnect to free the handle and prevent + * further connection attempts. + * + * @param serviceName name of the service + * @param resultHandler called with the result of the request + */ + public void requestServiceStop(String serviceName, ResultHandler resultHandler) { + + } + + /** + * Request for a service to be started. + * + * @param serviceName name of the service + */ + public void requestServiceStart(String serviceName, ResultHandler resultHandler) { + + } +} diff --git a/src/main/java/org/gnunet/arm/ArmMonitor.java b/src/main/java/org/gnunet/arm/ArmMonitor.java new file mode 100644 index 0000000..641b862 --- /dev/null +++ b/src/main/java/org/gnunet/arm/ArmMonitor.java @@ -0,0 +1,27 @@ +/* + This file is part of GNUnet. + (C) 2012, 2013 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.arm; + +/** + * API for monitoring ARM services. + */ +public class ArmMonitor { +} diff --git a/src/main/java/org/gnunet/arm/ResultHandler.java b/src/main/java/org/gnunet/arm/ResultHandler.java new file mode 100644 index 0000000..05c34f9 --- /dev/null +++ b/src/main/java/org/gnunet/arm/ResultHandler.java @@ -0,0 +1,31 @@ +/* + This file is part of GNUnet. + (C) 2012, 2013 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.arm; + +/** + * Created with IntelliJ IDEA. + * User: dold + * Date: 10/7/13 + * Time: 4:00 PM + * To change this template use File | Settings | File Templates. + */ +public interface ResultHandler { +} diff --git a/src/main/java/org/gnunet/arm/ServiceListHandler.java b/src/main/java/org/gnunet/arm/ServiceListHandler.java new file mode 100644 index 0000000..8d9de04 --- /dev/null +++ b/src/main/java/org/gnunet/arm/ServiceListHandler.java @@ -0,0 +1,28 @@ +/* + This file is part of GNUnet. + (C) 2012, 2013 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.arm; + + +import java.util.List; + +public interface ServiceListHandler { + void onServiceList(List services); +} diff --git a/src/main/java/org/gnunet/arm/ServiceStatusHandler.java b/src/main/java/org/gnunet/arm/ServiceStatusHandler.java new file mode 100644 index 0000000..cedcc48 --- /dev/null +++ b/src/main/java/org/gnunet/arm/ServiceStatusHandler.java @@ -0,0 +1,25 @@ +/* + This file is part of GNUnet. + (C) 2012, 2013 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.arm; + +public interface ServiceStatusHandler { + +} diff --git a/src/main/java/org/gnunet/arm/messages/ListResultMessage.java b/src/main/java/org/gnunet/arm/messages/ListResultMessage.java new file mode 100644 index 0000000..03f995f --- /dev/null +++ b/src/main/java/org/gnunet/arm/messages/ListResultMessage.java @@ -0,0 +1,41 @@ +/* + This file is part of GNUnet. + (C) 2012, 2013 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.arm.messages; + +import org.gnunet.construct.*; +import org.gnunet.util.GnunetMessage; + +@UnionCase(13) +public class ListResultMessage implements GnunetMessage.Body { + public class StringMessage implements Message { + @ZeroTerminatedString + public String string; + } + + @UInt64 + public long requestId; + + @UInt16 + public int count; + + @FillWith + public StringMessage[] services; +} diff --git a/src/main/java/org/gnunet/arm/messages/RequestMessage.java b/src/main/java/org/gnunet/arm/messages/RequestMessage.java new file mode 100644 index 0000000..fa0c18c --- /dev/null +++ b/src/main/java/org/gnunet/arm/messages/RequestMessage.java @@ -0,0 +1,25 @@ +/* + This file is part of GNUnet. + (C) 2012, 2013 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.arm.messages; + + +public class RequestMessage { +} diff --git a/src/main/java/org/gnunet/arm/messages/ResultMessage.java b/src/main/java/org/gnunet/arm/messages/ResultMessage.java new file mode 100644 index 0000000..4883c14 --- /dev/null +++ b/src/main/java/org/gnunet/arm/messages/ResultMessage.java @@ -0,0 +1,35 @@ +/* + This file is part of GNUnet. + (C) 2012, 2013 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.arm.messages; + +import org.gnunet.construct.UInt32; +import org.gnunet.construct.UInt64; +import org.gnunet.construct.UnionCase; +import org.gnunet.util.GnunetMessage; + +@UnionCase(10) +public class ResultMessage implements GnunetMessage.Body { + @UInt64 + public long requestId; + + @UInt32 + public int result; +} diff --git a/src/main/java/org/gnunet/arm/messages/StatusMessage.java b/src/main/java/org/gnunet/arm/messages/StatusMessage.java new file mode 100644 index 0000000..cdfde6c --- /dev/null +++ b/src/main/java/org/gnunet/arm/messages/StatusMessage.java @@ -0,0 +1,61 @@ +/* + This file is part of GNUnet. + (C) 2012, 2013 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +/* + This file is part of GNUnet. + (C) 2012, 2013 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +package org.gnunet.arm.messages; + +import org.gnunet.construct.*; +import org.gnunet.util.GnunetMessage; + +@UnionCase(11) +public class StatusMessage implements GnunetMessage.Body { + public class StringMessage implements Message { + @ZeroTerminatedString + public String string; + } + + @UInt64 + public long requestId; + + @UInt32 + public int status; + + @ZeroTerminatedString + public String serviceName; +} -- cgit v1.2.3