andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 1 | /* |
| 2 | * jndn-utils |
| 3 | * Copyright (c) 2015, Intel Corporation. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms and conditions of the GNU Lesser General Public License, |
| 7 | * version 3, as published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope it will be useful, but WITHOUT ANY |
| 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| 12 | * more details. |
| 13 | */ |
andrewsbrown | 13b11c5 | 2015-07-02 14:23:15 -0700 | [diff] [blame] | 14 | package com.intel.jndn.utils; |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 15 | |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 16 | import net.named_data.jndn.Data; |
andrewsbrown | 86088d7 | 2015-05-07 01:38:29 +0100 | [diff] [blame] | 17 | import net.named_data.jndn.Face; |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 18 | import net.named_data.jndn.Name; |
andrewsbrown | 86088d7 | 2015-05-07 01:38:29 +0100 | [diff] [blame] | 19 | import net.named_data.jndn.OnInterestCallback; |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 20 | |
Andrew Brown | 85234ea | 2016-09-07 13:41:29 -0700 | [diff] [blame] | 21 | import java.util.concurrent.ScheduledThreadPoolExecutor; |
| 22 | |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 23 | /** |
| 24 | * Base interface for defining a server; see descendant interfaces for different |
| 25 | * modes of serving packets. This class extends {@link Runnable} expecting |
| 26 | * implementing classes to do any necessary event processing in the |
| 27 | * {@link Runnable#run()} block, thus allowing different ways to manage servers |
| 28 | * (e.g. single-thread vs {@link ScheduledThreadPoolExecutor}. |
| 29 | * |
Andrew Brown | 85234ea | 2016-09-07 13:41:29 -0700 | [diff] [blame] | 30 | * @author Andrew Brown, andrew.brown@intel.com |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 31 | */ |
andrewsbrown | 86088d7 | 2015-05-07 01:38:29 +0100 | [diff] [blame] | 32 | public interface Server extends Runnable, OnInterestCallback { |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * @return the {@link Name} prefix this server is serving on. |
| 36 | */ |
Andrew Brown | 85234ea | 2016-09-07 13:41:29 -0700 | [diff] [blame] | 37 | Name getPrefix(); |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 38 | |
| 39 | /** |
andrewsbrown | d4bc52a | 2015-04-02 10:47:53 -0700 | [diff] [blame] | 40 | * @return the registered prefix ID of the server on the {@link Face} or -1 if |
| 41 | * unregistered |
| 42 | */ |
Andrew Brown | 85234ea | 2016-09-07 13:41:29 -0700 | [diff] [blame] | 43 | long getRegisteredPrefixId(); |
andrewsbrown | d4bc52a | 2015-04-02 10:47:53 -0700 | [diff] [blame] | 44 | |
| 45 | /** |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 46 | * Add a stage to the server pipeline. Each stage should be processed once the |
| 47 | * server has the {@link Data} packet available to send (e.g. after a callback |
| 48 | * has produced a packet); also, stages should be processed in the order they |
| 49 | * are added. |
| 50 | * |
andrewsbrown | 13b11c5 | 2015-07-02 14:23:15 -0700 | [diff] [blame] | 51 | * @param stage a Data-to-Data processing stage |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 52 | */ |
Andrew Brown | 85234ea | 2016-09-07 13:41:29 -0700 | [diff] [blame] | 53 | void addPostProcessingStage(ProcessingStage<Data, Data> stage); |
andrewsbrown | 4dddd47 | 2015-04-01 14:28:46 -0700 | [diff] [blame] | 54 | } |