Skip to content

YARN-11326. [Federation] Add RM FederationStateStoreService Metrics. #4963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fa42bae
YARN-11326. [Federation] Add RM FederationStateStoreService Metrics.
Oct 4, 2022
b164bd3
YARN-11326. Fix CheckStyle.
Oct 4, 2022
8aa81a9
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Oct 5, 2022
a913c33
YARN-11326. Fix Check Style.
Oct 5, 2022
460d332
YARN-11326. Refactor Some Metric Code.
Oct 6, 2022
d5e7538
YARN-11326. Fix CheckStyle.
Oct 6, 2022
b14d43b
YARN-11326. Fix CheckStyle.
Oct 6, 2022
a127c35
YARN-11326. Fix CheckStyle.
Oct 6, 2022
7e0a9d4
Merge branch 'trunk' into YARN-11326
slfan1989 Oct 13, 2022
9ed1f3a
Merge branch 'trunk' into YARN-11326
slfan1989 Oct 14, 2022
6f7fc19
YARN-11326. Fix CheckStyle.
Oct 14, 2022
5614886
YARN-11326. Fix CheckStyle.
Oct 14, 2022
52a72ab
YARN-11326. Add Junit Test.
Oct 18, 2022
b9a4eb0
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Oct 27, 2022
30ee750
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Nov 1, 2022
9e2e40c
YARN-11326. Fix CheckStyle.
Nov 2, 2022
64ab71e
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Nov 4, 2022
77b784d
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Nov 7, 2022
6abdc0e
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Nov 10, 2022
3ae3e39
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Nov 16, 2022
2b9ba9f
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Dec 1, 2022
3c4cef5
YARN-11326. Fix CheckStyle.
Dec 1, 2022
46ed46b
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Dec 2, 2022
17cefac
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Dec 9, 2022
13b5870
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Dec 15, 2022
2298bae
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Dec 20, 2022
2505955
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Jan 13, 2023
ad3f2c8
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Mar 11, 2023
fe0c056
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Mar 27, 2023
1e99166
YARN-11326. Fix CheckStyle.
Mar 30, 2023
8387258
YARN-11326. Fix CheckStyle.
Apr 1, 2023
001a96a
YARN-11326. Fix CheckStyle.
Apr 1, 2023
fa52991
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Apr 5, 2023
d15542a
YARN-11326. Fix CheckStyle.
Apr 6, 2023
fac9676
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Apr 7, 2023
c21a998
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Apr 11, 2023
4ef0b90
Merge branch 'apache:trunk' into YARN-11326
slfan1989 Apr 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.hadoop.yarn.server.resourcemanager.federation;

import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.federation.store.FederationStateStore;
import org.apache.hadoop.yarn.util.Clock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;
import java.util.Arrays;

/**
* Class to define client method,params and arguments.
*/
public class FederationClientMethod<R> {

public static final Logger LOG =
LoggerFactory.getLogger(FederationClientMethod.class);

/**
* List of parameters: static and dynamic values, matchings types.
*/
private final Object[] params;

/**
* List of method parameters types, matches parameters.
*/
private final Class<?>[] types;

/**
* String name of the method.
*/
private final String methodName;

private FederationStateStore stateStoreClient = null;

private Clock clock = null;

private Class<R> clazz;

public FederationClientMethod(String method, Class<?>[] pTypes, Object... pParams)
throws YarnException {
if (pParams.length != pTypes.length) {
throw new YarnException("Invalid parameters for method " + method);
}

this.params = pParams;
this.types = Arrays.copyOf(pTypes, pTypes.length);
this.methodName = method;
}

public FederationClientMethod(String method, Class pTypes, Object pParams)
throws YarnException {
this(method, new Class[]{pTypes}, new Object[]{pParams});
}

public FederationClientMethod(String method, Class pTypes, Object pParams, Class<R> rTypes,
FederationStateStore fedStateStore, Clock fedClock) throws YarnException {
this(method, pTypes, pParams);
this.stateStoreClient = fedStateStore;
this.clock = fedClock;
this.clazz = rTypes;
}

public Object[] getParams() {
return Arrays.copyOf(this.params, this.params.length);
}

public String getMethodName() {
return methodName;
}

/**
* Get the calling types for this method.
*
* @return An array of calling types.
*/
public Class<?>[] getTypes() {
return Arrays.copyOf(this.types, this.types.length);
}

/**
* We will use the invoke method to call the method in FederationStateStoreService.
*
* @return The result returned after calling the interface.
* @throws YarnException yarn exception.
*/
protected R invoke() throws YarnException {
try {
long startTime = clock.getTime();
Method method = FederationStateStore.class.getMethod(methodName, types);
R result = clazz.cast(method.invoke(stateStoreClient, params));

long stopTime = clock.getTime();
FederationStateStoreServiceMetrics.succeededStateStoreServiceCall(
methodName, stopTime - startTime);
return result;
} catch (Exception e) {
LOG.error("stateStoreClient call method {} error.", methodName, e);
FederationStateStoreServiceMetrics.failedStateStoreServiceCall(methodName);
throw new YarnException(e);
}
}
}
Loading