Commit 0f8ee393 authored by chenyuxi's avatar chenyuxi

上传已结束的

parent 42859f51
/*
* Copyright 2007-present the original author or 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
*
* https://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.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dapr.com.client</groupId>
<artifactId>dapr-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>dapr client</name>
<description>dapr client</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<!--<mainClass>server.JTServer</mainClass>-->
<mainClass>dapr.com.client.DaprClientApplication</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- 此处指定继承合并 -->
<phase>package</phase> <!-- 绑定到打包阶段 -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package dapr.com.client;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class DaprClientApplication {
private final static String saveBodyTmpl="{\"content\": \"%s\"}";
private final static String delSelBodyTmpl="{\"id\": \"%s\"}";
private final static String updateBodyTmpl="{\"id\": \"%s\", \"content\": \"%s\"}";
public static void main(String[] args) throws InterruptedException {
Thread sendThread = new Thread(new Runnable() {
public void run() {
int i=16;
//while(!Thread.interrupted()){
try {
Thread.sleep(10000);
i++;
String str = "第"+ i +"个意见~~~";
// 增
String body=String.format(saveBodyTmpl,str);
save(body);
// 改
// String body=String.format(updateBodyTmpl, String.valueOf(i), str);
// update(body);
// 删,查
// String body=String.format(delSelBodyTmpl, String.valueOf(i));
// select(body);
// delete(body);
} catch (Exception e) {
e.printStackTrace();
}
// }
}
});
sendThread.start();
Thread.sleep(5*60*60*1000);
}
/**
* 新增信息
* @param body
* @throws IOException
*/
private static void save(String body) throws IOException {
sendRequest(body,"save");
}
private static void update(String body) throws IOException {
sendRequest(body,"update");
}
private static void select(String body) throws IOException {
sendRequest(body,"select");
}
private static void delete(String body) throws IOException {
sendRequest(body,"delete");
}
/**
*
* @param body
* @param mothed
* @throws IOException
*/
private static void sendRequest(String body, String mothed) throws IOException {
String httpPort = System.getenv("DAPR_HTTP_PORT");
if (httpPort == null) {
httpPort = "3500";
}
String resultUrl = "http://121.43.155.15:" + httpPort + "/v1.0/invoke/java-service/method/" + mothed;
URL url = new URL(resultUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setUseCaches(false);
connection.setDoOutput(true);
connection.setDoInput(true);
System.out.println("request body:"+body);
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.write(body.getBytes("UTF-8"));
out.flush();
out.close();
connection.connect();
BufferedReader bReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
String line, resultStr = "";
while (null != (line = bReader.readLine())) {
resultStr += line;
}
System.out.println(resultStr);
bReader.close();
}
}
#Generated by Maven
#Wed Nov 03 15:42:39 CST 2021
version=0.0.1-SNAPSHOT
groupId=dapr.com.client
artifactId=dapr-client
dapr\com\client\DaprClientApplication.class
dapr\com\client\DaprClientApplication$1.class
E:\JavaLearn\client\src\main\java\dapr\com\client\DaprClientApplication.java
dapr-java @ b988d233
Subproject commit b988d23334d90564b9b3440367dff491fe264177
Label,# 样本,平均值,最小值,最大值,标准偏差,异常 %,吞吐量,接收 KB/sec,发送 KB/sec,平均字节数
dapr-select,6000,1553,0,50324,2564.36,34.583%,37.29349,17.06,7.49,468.3
总体,6000,1553,0,50324,2564.36,34.583%,37.29349,17.06,7.49,468.3
Label,# 样本,平均值,中位数,90% 百分位,95% 百分位,99% 百分位,最小值,最大值,异常 %,吞吐量,接收 KB/sec,发送 KB/sec
dapr-select,6000,1553,534,4283,7042,11321,0,50324,34.583%,37.29349,17.06,7.49
总体,6000,1553,534,4283,7042,11321,0,50324,34.583%,37.29349,17.06,7.49
# 在线笔记链接
## dapr 安装:
https://26cb8fd0.wiz06.com/wapp/pages/view/share/s/0COU_g3GyN7G2g4Aky3OG7dz2KFC5w0UoN7I2wmbT_29EAVq
## dapr服务调用 + 请求MySQL:
https://26cb8fd0.wiz06.com/wapp/pages/view/share/s/0COU_g3GyN7G2g4Aky3OG7dz2IL5Rg0X917I2xsbtt2FcMzz
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment