This project has retired. For details please refer to its Attic page.
Source code
001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.reef.io.network.group.impl.config;
020
021import org.apache.reef.io.network.group.api.config.OperatorSpec;
022import org.apache.reef.io.network.group.impl.utils.Utils;
023import org.apache.reef.io.serialization.Codec;
024
025
026/**
027 * The specification for the broadcast operator.
028 */
029public class BroadcastOperatorSpec implements OperatorSpec {
030  private final String senderId;
031
032  /**
033   * Codec to be used to serialize data.
034   */
035  private final Class<? extends Codec> dataCodecClass;
036
037
038  public BroadcastOperatorSpec(final String senderId,
039                               final Class<? extends Codec> dataCodecClass) {
040    super();
041    this.senderId = senderId;
042    this.dataCodecClass = dataCodecClass;
043  }
044
045  public String getSenderId() {
046    return senderId;
047  }
048
049  @Override
050  public Class<? extends Codec> getDataCodecClass() {
051    return dataCodecClass;
052  }
053
054  @Override
055  public String toString() {
056    return "Broadcast Operator Spec: [sender=" + senderId + "] [dataCodecClass=" + Utils.simpleName(dataCodecClass)
057        + "]";
058  }
059
060  public static Builder newBuilder() {
061    return new BroadcastOperatorSpec.Builder();
062  }
063
064  public static class Builder implements org.apache.reef.util.Builder<BroadcastOperatorSpec> {
065    private String senderId;
066
067    private Class<? extends Codec> dataCodecClass;
068
069
070    public Builder setSenderId(final String senderId) {
071      this.senderId = senderId;
072      return this;
073    }
074
075    public Builder setDataCodecClass(final Class<? extends Codec> codecClazz) {
076      this.dataCodecClass = codecClazz;
077      return this;
078    }
079
080    @Override
081    public BroadcastOperatorSpec build() {
082      return new BroadcastOperatorSpec(senderId, dataCodecClass);
083    }
084  }
085
086}