在Google Cloud Platform中,我有一个包含三个正在运行的实例的Container-Cluster.我现在想从我的终端连接,以便能够运行kubectl命令.为此,我运行了命令
gcloud container clusters get-credentials cluster-1 --zone europe-west1-b --project project-id
Run Code Online (Sandbox Code Playgroud)
我当然使用真正的项目名称.这是点击"与群集连接"时仪表板显示的命令.该命令的输出是:
Fetching cluster endpoint and auth data.
kubeconfig entry generated for cluster-1.
Run Code Online (Sandbox Code Playgroud)
但是当我kubectl之后运行命令时,kubectl cluster-info我总是得到:
Unable to connect to the server: oauth2: cannot fetch token: 400 Bad Request
Response: {
"error" : "invalid_grant",
"error_description" : "Token has been revoked."
}
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?gcloud像gcloud container clusters list工作的命令
我有一个包含几个选项的对象,其中可选项不为null,我想将其值作为参数传递给需要多个参数的方法.
目前我有一个代码块,如下所示:
if (dealerRequest.getIsApproved().isPresent()) {
repository.updateDealerPartnerFinanceIsApproved(dealerRequest.getDealerId(), dealerRequest.getIsApproved().get());
}
if (dealerRequest.getIsOptedIn().isPresent()) {
repository.updateDealerPartnerFinanceOptedIn(dealerRequest.getDealerId(), dealerRequest.getIsOptedIn().get());
}
Run Code Online (Sandbox Code Playgroud)
我知道检查该值是存在的,然后稍后获取它比以前的空检查更有用; 但是我不知道在这种情况下如何使用它们呢?
理想情况下,我会将.map()作为我仓库中方法的可选项,但后来我不知道如何传递(如果可以的话)第二个参数?有更简洁的方法吗?
我们正面临与微服务架构有关的性能问题。
假设有用于用户和帐户管理的微服务。其中有 api 之类的
GET /users/{id}
GET /users (arrount 6 million users)
GET /accounts/{accountId}
GET /accounts
and Other Operations on user and account
Run Code Online (Sandbox Code Playgroud)
我们还有其他微服务,用于跟踪用户活动并列出用户在上次登录时所做的所有活动。
GET /user/activity/{userId} (on an average 1000 to 10000 records)
Run Code Online (Sandbox Code Playgroud)
我们为销售和营销团队提供基于搜索条件的个人用户活动和用户信息和帐户信息的保护,
let's say search criteria is like : get all user activies who are located in colombia
Algorithm :
1)Get /users ? location = colombia
2)then for individual user Get /user/activity/{userId}
Run Code Online (Sandbox Code Playgroud)
这就像连接来自不同数据库的两个表。
它非常慢并且会产生很多性能问题。
我所想到的是通过一项工作复制其他微服务中的用户表,以确保它是最新的并且只使用一个 api
GET /user/activities?location=colombia.
Run Code Online (Sandbox Code Playgroud)
但是复制表(用户)打破了微服务架构的主要基础
有没有其他方法可以做到或支持这种类型的过滤条件,这些条件连接来自不同微服务的表。
我有一个简单的,@RestController并希望响应两者JSON或XML取决于http标头content-type.
问题:我总是只得到XML回应,而不是JSON.当然我Content-Type: application/json用作http标头.
以下配置中可能缺少什么?
@RestController
public void MyServlet {
@RequestMapping(value = "test", method = RequestMethod.GET,
produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE})
public MyResponse test() {
return new MyResponse();
}
}
@XmlRootElement
public class MyResponse {
private String test = "somevalue";
//getter, setter
}
Run Code Online (Sandbox Code Playgroud)
pom.xml中:
<!-- as advised in: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-spring-mvc.html -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-asl</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
有趣的是:如果我切换生产声明:
produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})那么我总是JSON走出去,永远不会XML!
所以问题是:为什么第一个MediaType总是有优先权,http头从不考虑?
我有这种代码
if(a == 3) {
if(b == 4) {
// do somthing
} else {
// do an other thing
}
} else {
// do the same other thing
}
Run Code Online (Sandbox Code Playgroud)
我想知道,当我在第一个时else,我怎么能去第二个,else因为它将执行相同的代码
谢谢
如果列表中的所有元素都满足给定的谓词,我应该如何编写一个返回true的函数?
考虑下面的列表和任何谓词:
val set = List(3, 4, 5, 6, 10)
Run Code Online (Sandbox Code Playgroud)
我想我需要写一些类似的东西:
def checkListElements(list parameters... ): Boolean = true if condition meet else false
Run Code Online (Sandbox Code Playgroud) 之前的代码是这样的——
try {
some other code
......
......
ByteArrayInputStream annoBais = new ByteArrayInputStream(annoBytes);
DataInputStream dis = new DataInputStream(annoBais);
InputStream annoStream = dis;
inputRecord.put("XMLStream", annoStream);
MappedRecord resultMappedRecord = (MappedRecord)interaction.execute(interactionSpec,inputRecord);
HashMap mappedAnnotIds = (HashMap)resultMappedRecord.get(("ResultHashMap").toString());
annoStream.close(); //closed here
annoBais.close(); // closed here
dis.close(); // closed here
......
......
some more code
}
Run Code Online (Sandbox Code Playgroud)
我把它改成——
try {
some other code
......
......
@lombok.Cleanup ByteArrayInputStream annoBais = new ByteArrayInputStream(annoBytes);
@lombok.Cleanup DataInputStream dis = new DataInputStream(annoBais);
@lombok.Cleanup InputStream annoStream = dis;
inputRecord.put("XMLStream", annoStream);
MappedRecord resultMappedRecord (MappedRecord)interaction.execute(interactionSpec,inputRecord);
HashMap …Run Code Online (Sandbox Code Playgroud) 我如何设置它的值?我不确定它是哪种格式。
import java.util.Date;
public class Test(
public Date dob;
public Test(){
dob = 10/01/1980 ?? "10/01/1980"
";
Run Code Online (Sandbox Code Playgroud) java ×5
architecture ×1
conditional ×1
gcloud ×1
if-statement ×1
java-8 ×1
json ×1
kubectl ×1
kubernetes ×1
lombok ×1
optional ×1
rest ×1
scala ×1
spring ×1
xml ×1