View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  
22  package org.opencastproject.distribution.api;
23  
24  import org.opencastproject.job.api.Job;
25  import org.opencastproject.mediapackage.MediaPackage;
26  import org.opencastproject.mediapackage.MediaPackageElement;
27  import org.opencastproject.mediapackage.MediaPackageException;
28  
29  import java.util.List;
30  import java.util.Set;
31  
32  /**
33   * Distributes elements from MediaPackages to distribution channels.
34   */
35  public interface StreamingDistributionService extends DistributionService {
36  
37    /**
38     * Checks if streaming is enabled for the current tenant.
39     *
40     * @return whether streaming is enabled for the current tenant
41     */
42    boolean publishToStreaming();
43  
44    Job distribute(String channelId, MediaPackage mediapackage, Set<String> elementIds)
45            throws DistributionException, MediaPackageException;
46  
47    Job retract(String channelId, MediaPackage mediaPackage, Set<String> elementIds)
48            throws DistributionException;
49  
50    /**
51     * Distributes the given elements synchronously. This should be used rarely since load balancing will be unavailable.
52     * However, since the dispatching logic is bypassed, synchronous execution is much faster. It is useful in interactive
53     * scenarios where you synchronously wait for job execution anyway and you don't want to make the user waiting for too
54     * long.
55     *
56     * @param channelId The channel to retract from.
57     * @param mediapackage A media package holding the elements to retract.
58     * @param elementIds The IDs of the elements to retract.
59     *
60     * @return The distributed elements.
61     * @throws DistributionException In case distribution fails.
62     */
63    List<MediaPackageElement> distributeSync(String channelId, MediaPackage mediapackage, Set<String> elementIds)
64            throws DistributionException;
65  
66    /**
67     * Retracts the given elements synchronously. This should be used rarely since load balancing will be unavailable.
68     * However, since the dispatching logic is bypassed, synchronous execution is much faster. It is useful in interactive
69     * scenarios where you synchronously wait for job execution anyway and you don't want to make the user waiting for too
70     * long.
71     *
72     * @param channelId The channel to retract from.
73     * @param mediaPackage A media package holding the elements to retract.
74     * @param elementIds The IDs of the elements to retract.
75     *
76     * @return The retracted elements.
77     *
78     * @throws DistributionException In case retraction fails.
79     */
80    List<MediaPackageElement> retractSync(String channelId, MediaPackage mediaPackage, Set<String> elementIds)
81            throws DistributionException;
82  }