forked from koordinator-sh/yarn-copilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: add proto and rm admin client (koordinator-sh#1)
Signed-off-by: 佑祎 <[email protected]>
- Loading branch information
1 parent
f0a168b
commit 7ebe7c1
Showing
49 changed files
with
23,424 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
vendor/ | ||
|
||
# Kubernetes Generated files - skip generated files, except for vendored files | ||
|
||
!vendor/**/zz_generated.* | ||
|
||
# editor and IDE paraphernalia | ||
.idea | ||
*.swp | ||
*.swo | ||
*~ | ||
|
||
.vscode | ||
.DS_Store | ||
|
||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
# goyarn | ||
use goyarn as native go clients for Apache Hadoop YARN. | ||
|
||
It includes an early version of Hadoop IPC client and requisite YARN client libraries to implement YARN applications completely in go (both YARN application-client and application-master). | ||
|
||
Koordinator extends `github.com/hortonworks/gohadoop` by implementing resource manager administration service and other clients. | ||
|
||
# Notes: | ||
Set HADOOP_CONF_DIR environment variable, and ensure the conf directory contains both *-default.xml and *-site.xml files. | ||
rm_update_node_resource.go is an example go YARN rpc client of rm-admin: call update node resource to do the updates. | ||
|
||
# Run rm_update_node_resource | ||
change the `host` and `port` to target node id | ||
$ HADOOP_CONF_DIR=conf go run examples/rm_update_node_resource.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hadoop=release-3.2.1-RC0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* | ||
Copyright 2013 The Cloudera Inc. | ||
Copyright 2023 The Koordinator Authors. | ||
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 auth | ||
|
||
import ( | ||
"bytes" | ||
"encoding/binary" | ||
"log" | ||
"os/user" | ||
"runtime" | ||
"strings" | ||
"unicode" | ||
|
||
hadoop_common "github.com/koordinator-sh/goyarn/apis/proto/hadoopcommon" | ||
) | ||
|
||
var ( | ||
RPC_HEADER []byte = []byte("hrpc") | ||
VERSION []byte = []byte{0x09} | ||
RPC_SERVICE_CLASS byte = 0x00 | ||
|
||
RPC_PROTOCOL_BUFFFER hadoop_common.RpcKindProto = hadoop_common.RpcKindProto_RPC_PROTOCOL_BUFFER | ||
RPC_FINAL_PACKET hadoop_common.RpcRequestHeaderProto_OperationProto = hadoop_common.RpcRequestHeaderProto_RPC_FINAL_PACKET | ||
RPC_DEFAULT_RETRY_COUNT int32 = hadoop_common.Default_RpcRequestHeaderProto_RetryCount | ||
CLIENT_PROTOCOL_VERSION uint64 = 1 | ||
) | ||
|
||
type AuthMethod byte | ||
|
||
const ( | ||
AUTH_SIMPLE AuthMethod = 0x50 | ||
AUTH_KERBEROS AuthMethod = 0x51 | ||
AUTH_TOKEN AuthMethod = 0x52 | ||
AUTH_PLAIN AuthMethod = 0x53 | ||
) | ||
|
||
func (authmethod AuthMethod) String() string { | ||
switch { | ||
case authmethod == AUTH_SIMPLE: | ||
return "SIMPLE" | ||
case authmethod == AUTH_KERBEROS: | ||
return "GSSAPI" | ||
case authmethod == AUTH_TOKEN: | ||
return "DIGEST-MD5" | ||
case authmethod == AUTH_PLAIN: | ||
return "PLAIN" | ||
} | ||
return "ERROR-UNKNOWN" | ||
} | ||
|
||
type AuthProtocol byte | ||
|
||
const ( | ||
AUTH_PROTOCOL_NONE AuthProtocol = 0x00 | ||
AUTH_PROTOCOL_SASL AuthProtocol = 0xDF | ||
) | ||
|
||
func (authprotocol AuthProtocol) String() string { | ||
switch { | ||
case authprotocol == AUTH_PROTOCOL_NONE: | ||
return "NONE" | ||
case authprotocol == AUTH_PROTOCOL_SASL: | ||
return "SASL" | ||
} | ||
return "ERROR-UNKNOWN" | ||
} | ||
|
||
func ConvertFixedToBytes(data interface{}) ([]byte, error) { | ||
buf := new(bytes.Buffer) | ||
err := binary.Write(buf, binary.BigEndian, data) | ||
return buf.Bytes(), err | ||
} | ||
|
||
func ConvertBytesToFixed(rawBytes []byte, data interface{}) error { | ||
buf := bytes.NewBuffer(rawBytes) | ||
err := binary.Read(buf, binary.BigEndian, data) | ||
return err | ||
} | ||
|
||
func GetCalleeRPCRequestHeaderProto(protocolName *string) *hadoop_common.RequestHeaderProto { | ||
pc, _, _, _ := runtime.Caller(1) // Callee Method Name | ||
fullName := runtime.FuncForPC(pc).Name() | ||
names := strings.Split(fullName, ".") | ||
unicodeName := []rune(names[len(names)-1]) | ||
unicodeName[0] = unicode.ToLower(unicodeName[0]) | ||
methodName := string(unicodeName) | ||
return &hadoop_common.RequestHeaderProto{MethodName: &methodName, DeclaringClassProtocolName: protocolName, ClientProtocolVersion: &CLIENT_PROTOCOL_VERSION} | ||
} | ||
|
||
func CreateSimpleUGIProto() (*hadoop_common.UserInformationProto, error) { | ||
// Figure the current user-name | ||
var username string | ||
if user, err := user.Current(); err != nil { | ||
log.Fatal("user.Current", err) | ||
return nil, err | ||
} else { | ||
username = user.Username | ||
} | ||
|
||
return &hadoop_common.UserInformationProto{EffectiveUser: nil, RealUser: &username}, nil | ||
} |
Oops, something went wrong.