Search in sources :

Example 36 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project java-docs-samples by GoogleCloudPlatform.

the class ListChannelEvents method listChannelEvents.

public static void listChannelEvents(String projectId, String location, String channelId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
        var listEventsRequest = ListEventsRequest.newBuilder().setParent(ChannelName.of(projectId, location, channelId).toString()).build();
        LivestreamServiceClient.ListEventsPagedResponse response = livestreamServiceClient.listEvents(listEventsRequest);
        System.out.println("Channel events:");
        for (Event event : response.iterateAll()) {
            System.out.println(event.getName());
        }
    }
}
Also used : Event(com.google.cloud.video.livestream.v1.Event) LivestreamServiceClient(com.google.cloud.video.livestream.v1.LivestreamServiceClient)

Example 37 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project yaks by citrusframework.

the class CreateChannelAction method doExecute.

@Override
public void doExecute(TestContext context) {
    Channel channel = new ChannelBuilder().withApiVersion(String.format("%s/%s", KnativeSupport.knativeMessagingGroup(), KnativeSupport.knativeApiVersion())).withNewMetadata().withNamespace(namespace(context)).withName(context.replaceDynamicContentInString(channelName)).withLabels(KnativeSettings.getDefaultLabels()).endMetadata().build();
    getKnativeClient().channels().inNamespace(namespace(context)).createOrReplace(channel);
}
Also used : Channel(io.fabric8.knative.messaging.v1.Channel) ChannelBuilder(io.fabric8.knative.messaging.v1.ChannelBuilder)

Example 38 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project ysoserial by frohoff.

the class JBoss method doRun.

private static void doRun(URI u, final Object payloadObject, String username, String password) {
    ConnectionProvider instance = null;
    ConnectionProviderContextImpl context = null;
    ConnectionHandler ch = null;
    Channel c = null;
    VersionedConnection vc = null;
    try {
        Logger logger = LogManager.getLogManager().getLogger("");
        logger.addHandler(new ConsoleLogHandler());
        logger.setLevel(Level.INFO);
        OptionMap options = OptionMap.builder().set(Options.SSL_ENABLED, u.getScheme().equals("https")).getMap();
        context = new ConnectionProviderContextImpl(options, "endpoint");
        instance = new HttpUpgradeConnectionProviderFactory().createInstance(context, options);
        String host = u.getHost();
        int port = u.getPort() > 0 ? u.getPort() : 9990;
        SocketAddress destination = new InetSocketAddress(host, port);
        ConnectionHandlerFactory chf = getConnection(destination, username, password, context, instance, options);
        ch = chf.createInstance(new ConnectionHandlerContextImpl(context));
        c = getChannel(context, ch, options);
        System.err.println("Connected");
        vc = makeVersionedConnection(c);
        MBeanServerConnection mbc = vc.getMBeanServerConnection(null);
        doExploit(payloadObject, mbc);
        System.err.println("DONE");
    } catch (Throwable e) {
        e.printStackTrace(System.err);
    } finally {
        cleanup(instance, context, ch, c, vc);
    }
}
Also used : ConnectionHandlerFactory(org.jboss.remoting3.spi.ConnectionHandlerFactory) InetSocketAddress(java.net.InetSocketAddress) Channel(org.jboss.remoting3.Channel) Logger(java.util.logging.Logger) Endpoint(org.jboss.remoting3.Endpoint) ConnectionProvider(org.jboss.remoting3.spi.ConnectionProvider) ConnectionHandler(org.jboss.remoting3.spi.ConnectionHandler) OptionMap(org.xnio.OptionMap) HttpUpgradeConnectionProviderFactory(org.jboss.remoting3.remote.HttpUpgradeConnectionProviderFactory) VersionedConnection(org.jboss.remotingjmx.VersionedConnection) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) MBeanServerConnection(javax.management.MBeanServerConnection)

Example 39 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project java-docs-samples by GoogleCloudPlatform.

the class CreateChannelEvent method createChannelEvent.

public static void createChannelEvent(String projectId, String location, String channelId, String eventId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
        var createEventRequest = CreateEventRequest.newBuilder().setParent(ChannelName.of(projectId, location, channelId).toString()).setEventId(eventId).setEvent(Event.newBuilder().setAdBreak(AdBreakTask.newBuilder().setDuration(Duration.newBuilder().setSeconds(30).build()).build()).setExecuteNow(true).build()).build();
        Event response = livestreamServiceClient.createEvent(createEventRequest);
        System.out.println("Channel event: " + response.getName());
    }
}
Also used : Event(com.google.cloud.video.livestream.v1.Event) LivestreamServiceClient(com.google.cloud.video.livestream.v1.LivestreamServiceClient)

Example 40 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project java-docs-samples by GoogleCloudPlatform.

the class TestUtils method cleanStaleChannels.

public static void cleanStaleChannels(String projectId, String location) {
    try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
        var listChannelsRequest = ListChannelsRequest.newBuilder().setParent(LocationName.of(projectId, location).toString()).build();
        LivestreamServiceClient.ListChannelsPagedResponse response = livestreamServiceClient.listChannels(listChannelsRequest);
        for (Channel channel : response.iterateAll()) {
            if (channel.getCreateTime().getSeconds() < Instant.now().getEpochSecond() - DELETION_THRESHOLD_TIME_HOURS_IN_SECONDS) {
                // Stop the channel
                try {
                    livestreamServiceClient.stopChannelAsync(channel.getName()).get(1, TimeUnit.MINUTES);
                } catch (ExecutionException e) {
                    // Ignore error if the channel isn't stopped or the stop operation times out.
                    e.printStackTrace();
                } catch (NotFoundException | InterruptedException | TimeoutException e) {
                    e.printStackTrace();
                    continue;
                }
                // Delete the channel events
                var listEventsRequest = ListEventsRequest.newBuilder().setParent(channel.getName()).build();
                LivestreamServiceClient.ListEventsPagedResponse eventsResponse = livestreamServiceClient.listEvents(listEventsRequest);
                for (Event event : eventsResponse.iterateAll()) {
                    var deleteEventRequest = DeleteEventRequest.newBuilder().setName(event.getName()).build();
                    livestreamServiceClient.deleteEvent(deleteEventRequest);
                }
                // Delete the channel
                var deleteChannelRequest = DeleteChannelRequest.newBuilder().setName(channel.getName()).build();
                livestreamServiceClient.deleteChannelAsync(deleteChannelRequest).get(1, TimeUnit.MINUTES);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    } catch (NotFoundException | InterruptedException | ExecutionException | TimeoutException e) {
        e.printStackTrace();
    }
}
Also used : Channel(com.google.cloud.video.livestream.v1.Channel) NotFoundException(com.google.api.gax.rpc.NotFoundException) IOException(java.io.IOException) Event(com.google.cloud.video.livestream.v1.Event) ExecutionException(java.util.concurrent.ExecutionException) LivestreamServiceClient(com.google.cloud.video.livestream.v1.LivestreamServiceClient) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

Channel (org.jboss.remoting3.Channel)41 IOException (java.io.IOException)29 Test (org.junit.Test)14 LivestreamServiceClient (com.google.cloud.video.livestream.v1.LivestreamServiceClient)13 Connection (org.jboss.remoting3.Connection)12 MessageInputStream (org.jboss.remoting3.MessageInputStream)12 CountDownLatch (java.util.concurrent.CountDownLatch)10 OpenListener (org.jboss.remoting3.OpenListener)10 MessageOutputStream (org.jboss.remoting3.MessageOutputStream)9 InetSocketAddress (java.net.InetSocketAddress)8 URI (java.net.URI)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)8 IoFuture (org.xnio.IoFuture)7 Channel (com.google.cloud.video.livestream.v1.Channel)6 URISyntaxException (java.net.URISyntaxException)6 ManagementClientChannelStrategy (org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy)6 FutureResult (org.xnio.FutureResult)6 ManagementChannelHandler (org.jboss.as.protocol.mgmt.ManagementChannelHandler)5 Endpoint (org.jboss.remoting3.Endpoint)5 Event (com.google.cloud.video.livestream.v1.Event)4