/*
 * Copyright 2019-present Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package com.facebook.buck.remoteexecution.event;

import com.facebook.buck.core.rules.BuildRule;
import com.facebook.buck.event.AbstractBuckEvent;
import com.facebook.buck.event.BuckEventBus;
import com.facebook.buck.event.EventKey;

/** Event to signal the end of building a rule remotely. */
public class RemoteBuildRuleExecutionEvent extends AbstractBuckEvent {

  private final BuildRule buildRule;
  private final long executionDurationMs;

  private RemoteBuildRuleExecutionEvent(
      EventKey eventKey, BuildRule buildRule, long executionDurationMs) {
    super(eventKey);
    this.buildRule = buildRule;
    this.executionDurationMs = executionDurationMs;
  }

  public BuildRule getBuildRule() {
    return buildRule;
  }

  public long getExecutionDurationMs() {
    return executionDurationMs;
  }

  @Override
  public String getEventName() {
    return RemoteBuildRuleExecutionEvent.class.getSimpleName();
  }

  @Override
  protected String getValueString() {
    return getBuildRule().getFullyQualifiedName() + getExecutionDurationMs();
  }

  /** Posts event of type RemoteBuildRuleExecutionEvent into {@link BuckEventBus} */
  public static void postEvent(
      BuckEventBus buckEventBus, BuildRule buildRule, long executionDurationMs) {
    buckEventBus.post(
        new RemoteBuildRuleExecutionEvent(EventKey.unique(), buildRule, executionDurationMs));
  }
}

@@ -1979,11 +1979,227 @@
 s));%0A  %7D
+%0A%0A  public static RemoteBuildRuleExecutionEvent createEvent(%0A      BuildRule buildRule, long executionDurationMs) %7B%0A    return new RemoteBuildRuleExecutionEvent(EventKey.unique(), buildRule, executionDurationMs);%0A  %7D
 %0A%7D%0A

Add remote rule exec time to total_time_ms