diff --git a/labs/kafka/KafkaEFTest/KafkaEFTest.csproj b/labs/kafka/KafkaEFTest/KafkaEFTest.csproj
index 730ddf42..c4370a67 100644
--- a/labs/kafka/KafkaEFTest/KafkaEFTest.csproj
+++ b/labs/kafka/KafkaEFTest/KafkaEFTest.csproj
@@ -1,4 +1,4 @@
-
+Exe
@@ -8,7 +8,7 @@
+
-
-
+
\ No newline at end of file
diff --git a/labs/kafka/KafkaEFTest/Program.cs b/labs/kafka/KafkaEFTest/Program.cs
index 00038372..d2821e20 100644
--- a/labs/kafka/KafkaEFTest/Program.cs
+++ b/labs/kafka/KafkaEFTest/Program.cs
@@ -1,5 +1,7 @@
using Confluent.Kafka;
using Microsoft.EntityFrameworkCore;
+using MySqlConnector;
+using Newtonsoft.Json;
using System;
using System.Threading;
using System.Threading.Tasks;
@@ -8,8 +10,9 @@ namespace KafkaEFTest
{
internal class Program
{
- static TimeSpan DefaultTimeout = TimeSpan.FromSeconds(30);
- private static void Main(string[] args)
+ private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(30);
+
+ private static void Main()
{
using (var db = new TestDbContext())
{
@@ -17,31 +20,37 @@ namespace KafkaEFTest
}
Task.Run(async () =>
{
+ var topic = "test-topic";
+ var config = new ProducerConfig
+ {
+ BootstrapServers = "localhost:9092",
+ TransactionalId = "test",
+ };
while (true)
{
- var entity = new TestEntity();
- using (var db = new TestDbContext())
+ using (var dbContext = new TestDbContext())
{
try
{
- using (var p = new ProducerBuilder(new ProducerConfig { BootstrapServers = "localhost:9092", TransactionalId = entity.Id.ToString() }).Build())
+ using (var producer = new ProducerBuilder(config).Build())
{
try
{
- p.InitTransactions(DefaultTimeout);
- p.BeginTransaction();
- db.Database.BeginTransaction();
- db.Tests.Add(entity);
- db.SaveChanges();
- var dr = await p.ProduceAsync("test-topic", new Message { Value = entity.Id + ":" + entity.Value });
- db.Database.CommitTransaction();
- p.CommitTransaction(DefaultTimeout);
- Console.WriteLine($"Delivered '{dr.Value}' to '{dr.TopicPartitionOffset}'");
+ var entity = new TestEntity();
+ producer.InitTransactions(DefaultTimeout);
+ producer.BeginTransaction();
+ dbContext.Database.BeginTransaction();
+ dbContext.Tests.Add(entity);
+ dbContext.SaveChanges();
+ var dr = await producer.ProduceAsync(topic, new Message { Key = "test_table", Value = JsonConvert.SerializeObject(entity) });
+ dbContext.Database.CommitTransaction();
+ producer.CommitTransaction(DefaultTimeout);
+ Console.WriteLine($"send message offset: '{dr.TopicPartitionOffset}' value: '{dr.Value}");
}
catch (Exception ex)//DbUpdateException//ProduceException
{
- db.Database.RollbackTransaction();
- p.AbortTransaction(DefaultTimeout);
+ dbContext.Database.RollbackTransaction();
+ producer.AbortTransaction(DefaultTimeout);
Console.WriteLine(ex.Message);
}
}
@@ -57,13 +66,17 @@ namespace KafkaEFTest
});
var conf = new ConsumerConfig
{
- GroupId = "test-consumer-group",
+ GroupId = "group_test",
BootstrapServers = "localhost:9092",
- AutoOffsetReset = AutoOffsetReset.Earliest
+ EnableAutoCommit = false,
+ StatisticsIntervalMs = 5000,
+ SessionTimeoutMs = 6000,
+ AutoOffsetReset = AutoOffsetReset.Earliest,
+ EnablePartitionEof = true
};
- using (var c = new ConsumerBuilder(conf).Build())
+ using (var consumer = new ConsumerBuilder(conf).Build())
{
- c.Subscribe("test-topic");
+ consumer.Subscribe("test-topic");
CancellationTokenSource cts = new CancellationTokenSource();
Console.CancelKeyPress += (_, e) =>
@@ -78,8 +91,26 @@ namespace KafkaEFTest
{
try
{
- var cr = c.Consume(cts.Token);
- Console.WriteLine($"Consumed message '{cr.Value}' at: '{cr.TopicPartitionOffset}'.");
+ var consumeResult = consumer.Consume(cts.Token);
+ if (consumeResult.IsPartitionEOF)
+ {
+ Console.WriteLine(
+ $"Reached end of topic {consumeResult.Topic}, partition {consumeResult.Partition}, offset {consumeResult.Offset}.");
+ continue;
+ }
+
+ Console.WriteLine($"group received message offset: '{consumeResult.TopicPartitionOffset}' key: {consumeResult.Message.Key} value: '{consumeResult.Message.Value}'");
+
+ Doris(consumeResult.Value);
+
+ try
+ {
+ consumer.Commit(consumeResult);
+ }
+ catch (KafkaException e)
+ {
+ Console.WriteLine($"Commit error: {e.Error.Reason}");
+ }
}
catch (ConsumeException e)
{
@@ -90,10 +121,51 @@ namespace KafkaEFTest
catch (OperationCanceledException)
{
// Ensure the consumer leaves the group cleanly and final offsets are committed.
- c.Close();
+ consumer.Close();
}
}
}
+
+ //create database test;
+ //CREATE USER 'usr' IDENTIFIED BY 'pwd';
+ //GRANT ALL ON test TO usr;
+ //CREATE TABLE IF NOT EXISTS test
+ //(
+ // `id` VARCHAR(64),
+ // `value` VARCHAR(128),
+ // `number` INT
+ //)
+ //UNIQUE KEY(`id`)
+ //distributed by hash(id) buckets 1
+ //properties(
+ // "replication_num" = "1"
+ //);
+
+ private static void Doris(string value)
+ {
+ try
+ {
+ var entity = JsonConvert.DeserializeObject(value);
+ var connectionString = "Server=localhost;Port=9030;Database=test;Uid=usr;Pwd=pwd;";
+ using (var conn = new MySqlConnection(connectionString))
+ {
+ conn.Open();
+ using (var cmd = conn.CreateCommand())
+ {
+ cmd.CommandTimeout = 60;
+ cmd.CommandText = $"insert into test (`id`,`value`,`number`) values ('{entity.Id}','{entity.Value}',{entity.Number})";
+ cmd.ExecuteNonQuery();
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.GetType().FullName);
+ //"Unknown database 'default_cluster:test'"
+ //errCode = 2, detailMessage = Unknown table 'test'
+ throw;
+ }
+ }
}
public class TestDbContext : DbContext
@@ -112,9 +184,11 @@ namespace KafkaEFTest
{
this.Id = Guid.NewGuid();
this.Value = DateTime.Now.Ticks.ToString();
+ this.Number = new Random((int)DateTime.Now.Ticks).Next();
}
public Guid Id { get; set; }
public string Value { get; set; }
+ public int Number { get; set; }
}
}
\ No newline at end of file
diff --git a/labs/kafka/docker-compose.yml b/labs/kafka/docker-compose.yml
index c8705ceb..fdf241a4 100644
--- a/labs/kafka/docker-compose.yml
+++ b/labs/kafka/docker-compose.yml
@@ -8,27 +8,55 @@ networks:
services:
zookeeper:
image: wurstmeister/zookeeper:latest
+ restart: always
ports:
- 2181:2181
networks:
default:
- ipv4_address: 172.172.0.171
+ ipv4_address: 172.172.0.201
kafka:
image: wurstmeister/kafka:2.13-2.6.0
restart: always
environment:
- KAFKA_ZOOKEEPER_CONNECT: 172.172.0.171:2181
- KAFKA_ADVERTISED_HOST_NAME: 172.172.0.170
+ KAFKA_ZOOKEEPER_CONNECT: 172.172.0.201:2181
+ KAFKA_ADVERTISED_HOST_NAME: localhost
+ KAFKA_HEAP_OPTS: "-Xmx256m -Xms256m"
+ volumes:
+ - ./docker/data/kafka:/kafka
+ ports:
+ - 9092:9092
+ networks:
+ default:
+ ipv4_address: 172.172.0.210
+ kafka-manager:
+ image: sheepkiller/kafka-manager
+ restart: always
+ environment:
+ ZK_HOSTS: 172.172.0.201
+ KAFKA_BROKERS: 172.172.0.210:9092
+ ports:
+ - "9010:9000"
+ networks:
+ default:
+ ipv4_address: 172.172.0.220
+ doris:
+ image: doris:0.12.0
+ restart: always
+ environment:
+ TZ: "Asia/Shanghai"
volumes:
- - /etc/localtime:/etc/localtime
- - /var/run/docker.sock:/var/run/docker.sock
+ #- ./conf/fe.conf:/opt/fe/conf/fe.conf
- ./log/fe:/opt/fe/log
- ./data/fe/doris-meta:/opt/fe/doris-meta
- - ./conf/be.conf:/opt/be/conf/be.conf
+ #- ./conf/be.conf:/opt/be/conf/be.conf
- ./data/be/storage:/opt/be/storage
ports:
- - 9092:9092
+ - 8081:8081
+ - 8030:8030
+ - 9030:9030
+ - 9050:9050
command: bash -c "/opt/fe/bin/start_fe.sh & /opt/be/bin/start_be.sh"
+ #mysql -h 127.0.0.1 -P9030 -u root -e 'ALTER SYSTEM ADD BACKEND "172.172.0.30:9050"'
networks:
default:
- ipv4_address: 172.172.0.170
+ ipv4_address: 172.172.0.30
diff --git a/labs/kafka/start.cmd b/labs/kafka/start.cmd
new file mode 100644
index 00000000..9534090b
--- /dev/null
+++ b/labs/kafka/start.cmd
@@ -0,0 +1 @@
+docker-compose -f docker-compose.yml up --remove-orphans --force-recreate -d
\ No newline at end of file
diff --git a/labs/kafka/stop.cmd b/labs/kafka/stop.cmd
new file mode 100644
index 00000000..356959e4
--- /dev/null
+++ b/labs/kafka/stop.cmd
@@ -0,0 +1 @@
+docker-compose down --remove-orphans
\ No newline at end of file
diff --git a/projects/WebMVC/wwwroot/components/iot/camera.html b/projects/WebMVC/wwwroot/components/iot/camera.html
index f34d32c0..97d40907 100644
--- a/projects/WebMVC/wwwroot/components/iot/camera.html
+++ b/projects/WebMVC/wwwroot/components/iot/camera.html
@@ -1,4 +1,4 @@
-
+
{{device.displayName}}
@@ -23,21 +23,21 @@
-
+
-
-
-
-
-
+
+
+
+
+
-
+
@@ -47,8 +47,7 @@
-
\ No newline at end of file
+ };
\ No newline at end of file
diff --git a/projects/WebMVC/wwwroot/components/iot/color-light.html b/projects/WebMVC/wwwroot/components/iot/color-light.html
index 43c3c9b8..10b99b2a 100644
--- a/projects/WebMVC/wwwroot/components/iot/color-light.html
+++ b/projects/WebMVC/wwwroot/components/iot/color-light.html
@@ -1,4 +1,4 @@
-
+
-
\ No newline at end of file
+ };
\ No newline at end of file
diff --git a/projects/WebMVC/wwwroot/components/iot/door.html b/projects/WebMVC/wwwroot/components/iot/door.html
index e0812fb7..bbeebb7e 100644
--- a/projects/WebMVC/wwwroot/components/iot/door.html
+++ b/projects/WebMVC/wwwroot/components/iot/door.html
@@ -13,16 +13,15 @@
-
-
+
+
-
\ No newline at end of file
+ };
\ No newline at end of file
diff --git a/projects/WebMVC/wwwroot/components/iot/socket.html b/projects/WebMVC/wwwroot/components/iot/socket.html
index a3e0a02d..1125dcd9 100644
--- a/projects/WebMVC/wwwroot/components/iot/socket.html
+++ b/projects/WebMVC/wwwroot/components/iot/socket.html
@@ -1,4 +1,4 @@
-
+
{{device.displayName}}
@@ -14,16 +14,15 @@
{{electricity}} kW‧h{{power}} W
-
-
+
+
-
\ No newline at end of file
+ };
\ No newline at end of file
diff --git a/projects/WebMVC/wwwroot/components/iot/switch.html b/projects/WebMVC/wwwroot/components/iot/switch.html
index 2032c415..0bcab67d 100644
--- a/projects/WebMVC/wwwroot/components/iot/switch.html
+++ b/projects/WebMVC/wwwroot/components/iot/switch.html
@@ -1,4 +1,4 @@
-
+
{{device.displayName}}
@@ -12,16 +12,14 @@
-
-
+
+
-
\ No newline at end of file
+ };
\ No newline at end of file
diff --git a/projects/WebMVC/wwwroot/components/iot/switch3.html b/projects/WebMVC/wwwroot/components/iot/switch3.html
index a11065d1..65801932 100644
--- a/projects/WebMVC/wwwroot/components/iot/switch3.html
+++ b/projects/WebMVC/wwwroot/components/iot/switch3.html
@@ -1,4 +1,4 @@
-
+
{{device.displayName}}
@@ -12,20 +12,18 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
\ No newline at end of file
+ };
\ No newline at end of file
diff --git a/projects/WebMVC/wwwroot/components/shared/display/imageurl.html b/projects/WebMVC/wwwroot/components/shared/display/imageurl.html
index de6940df..2b109992 100644
--- a/projects/WebMVC/wwwroot/components/shared/display/imageurl.html
+++ b/projects/WebMVC/wwwroot/components/shared/display/imageurl.html
@@ -1,16 +1,14 @@
-
+
-
\ No newline at end of file
+ };
\ No newline at end of file
diff --git a/projects/WebMVC/wwwroot/components/shared/edit/html.html b/projects/WebMVC/wwwroot/components/shared/edit/html.html
index 7800035b..d4ff6b1b 100644
--- a/projects/WebMVC/wwwroot/components/shared/edit/html.html
+++ b/projects/WebMVC/wwwroot/components/shared/edit/html.html
@@ -1,10 +1,9 @@
-
+
-
\ No newline at end of file
+ };
\ No newline at end of file
diff --git a/projects/WebMVC/wwwroot/components/shared/edit/imageurl.html b/projects/WebMVC/wwwroot/components/shared/edit/imageurl.html
index cdd02923..21c444ec 100644
--- a/projects/WebMVC/wwwroot/components/shared/edit/imageurl.html
+++ b/projects/WebMVC/wwwroot/components/shared/edit/imageurl.html
@@ -1,4 +1,4 @@
-
+
@@ -6,8 +6,7 @@
-
\ No newline at end of file
+ };
\ No newline at end of file
diff --git a/projects/WebMVC/wwwroot/components/shared/layout.html b/projects/WebMVC/wwwroot/components/shared/layout.html
index b77715ca..fbc1e77a 100644
--- a/projects/WebMVC/wwwroot/components/shared/layout.html
+++ b/projects/WebMVC/wwwroot/components/shared/layout.html
@@ -382,8 +382,7 @@
-
\ No newline at end of file
+ }
\ No newline at end of file
diff --git a/projects/WebMVC/wwwroot/index.html b/projects/WebMVC/wwwroot/index.html
index 57ba9b8f..5eed3428 100644
--- a/projects/WebMVC/wwwroot/index.html
+++ b/projects/WebMVC/wwwroot/index.html
@@ -13,7 +13,7 @@
-
+
diff --git a/projects/WebMVC/wwwroot/js/components.js b/projects/WebMVC/wwwroot/js/components.js
index eae42477..941b75a1 100644
--- a/projects/WebMVC/wwwroot/js/components.js
+++ b/projects/WebMVC/wwwroot/js/components.js
@@ -1,25 +1,25 @@
Vue.component('pagination', function (resolve, reject) {
- axios.get("/components/shared/pagination.html").then(function (response) {
+ axios.get("components/shared/pagination.html").then(function (response) {
resolve(parseModel(response));
});
});
Vue.component('layout', function (resolve, reject) {
- axios.get("/components/shared/layout.html").then(function (response) {
+ axios.get("components/shared/layout.html").then(function (response) {
resolve(parseModel(response));
});
});
Vue.component('list', function (resolve, reject) {
- axios.get("/components/shared/list.html").then(function (response) {
+ axios.get("components/shared/list.html").then(function (response) {
resolve(parseModel(response));
});
});
Vue.component('display', function (resolve, reject) {
- axios.get("/components/shared/display.html").then(function (response) {
+ axios.get("components/shared/display.html").then(function (response) {
resolve(parseModel(response));
});
});
Vue.component('update', function (resolve, reject) {
- axios.get("/components/shared/update.html").then(function (response) {
+ axios.get("components/shared/update.html").then(function (response) {
resolve(parseModel(response));
});
-});
\ No newline at end of file
+});
diff --git a/projects/WebMVC/wwwroot/js/form.js b/projects/WebMVC/wwwroot/js/form.js
index d55ccf13..c4a8be01 100644
--- a/projects/WebMVC/wwwroot/js/form.js
+++ b/projects/WebMVC/wwwroot/js/form.js
@@ -21,6 +21,6 @@
];
for (var i = 0; i < formComponents.length; i++) {
var name = formComponents[i];
- var url = "/components/shared/" + name.replace('-', '/') + ".html";
+ var url = "components/shared/" + name.replace('-', '/') + ".html";
vueComponent(name, url);
}
\ No newline at end of file
diff --git a/projects/WebMVC/wwwroot/js/iot.js b/projects/WebMVC/wwwroot/js/iot.js
index 1f0eb72b..4b24c220 100644
--- a/projects/WebMVC/wwwroot/js/iot.js
+++ b/projects/WebMVC/wwwroot/js/iot.js
@@ -88,7 +88,7 @@ var iotComponents = [
];
for (var i = 0; i < iotComponents.length; i++) {
var name = 'iot-'+iotComponents[i];
- var url = "/components/iot/" + iotComponents[i] + ".html";
+ var url = "components/iot/" + iotComponents[i] + ".html";
vueComponent(name, url);
}
var deviceInfo = [];
diff --git a/projects/WebMVC/wwwroot/js/route.js b/projects/WebMVC/wwwroot/js/route.js
index ff8a52d8..823ff439 100644
--- a/projects/WebMVC/wwwroot/js/route.js
+++ b/projects/WebMVC/wwwroot/js/route.js
@@ -19,7 +19,7 @@ router.beforeEach((to, from, next) => {
var name = url.replace(/\//g, "-").replace(/\./g, "-").substring(1);
var route = routes[name];
if (!route) {
- axios.get(url).then(function (response) {
+ axios.get(url.substring(1)).then(function (response) {
var model = parseModel(response);
route = {
name: name,
diff --git a/publish/dslx/linux-x64/publish/docker/conf/website/nginx.conf b/publish/dslx/linux-x64/publish/docker/conf/website/nginx.conf
index e371f872..06c184ae 100644
--- a/publish/dslx/linux-x64/publish/docker/conf/website/nginx.conf
+++ b/publish/dslx/linux-x64/publish/docker/conf/website/nginx.conf
@@ -1,4 +1,4 @@
-user root;
+user root;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
@@ -16,26 +16,32 @@ http {
keepalive_timeout 65;
types {
application/vnd.android.package-archive apk;
- application/iphone pxl ipa;
- text/plain plist;
+ application/iphone pxl ipa;
+ text/plain plist;
}
upstream gateway {
server 172.172.0.12;
}
+ server {
+ listen 80;
+ server_name iot.edusoa.com;
+ return 301 https://$host$request_uri;
+ }
+
server {
#listen 80;
listen 443;
server_name iot.edusoa.com;
- ssl on;
- ssl_certificate edusoa.pem;
- ssl_certificate_key edusoa.key;
- ssl_session_timeout 5m;
- ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
- ssl_ciphers HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM;
- ssl_prefer_server_ciphers on;
+ ssl on;
+ ssl_certificate edusoa.pem;
+ ssl_certificate_key edusoa.key;
+ ssl_session_timeout 5m;
+ ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
+ ssl_ciphers HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM;
+ ssl_prefer_server_ciphers on;
location / {
root /root/nginx/html/desktop;
diff --git a/publish/src/linux-x64/publish/docker-compose.temp.yml b/publish/src/linux-x64/publish/docker-compose.temp.yml
deleted file mode 100644
index 2f00303e..00000000
--- a/publish/src/linux-x64/publish/docker-compose.temp.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-#docker-compose up -d
-version: "3.8"
-services:
- zookeeper:
- image: wurstmeister/zookeeper:latest
- restart: always
- ports:
- - 2181:2181
- networks:
- default:
- ipv4_address: 172.172.0.201
- kafka:
- image: wurstmeister/kafka:2.13-2.6.0
- restart: always
- environment:
- KAFKA_ZOOKEEPER_CONNECT: 172.172.0.201:2181
- KAFKA_ADVERTISED_HOST_NAME: localhost
- KAFKA_HEAP_OPTS: "-Xmx256m -Xms256m"
- volumes:
- - ./docker/data/kafka:/kafka
- ports:
- - 9092:9092
- networks:
- default:
- ipv4_address: 172.172.0.210
- kafka-manager:
- image: sheepkiller/kafka-manager
- environment:
- ZK_HOSTS: 172.172.0.201
- KAFKA_BROKERS: 172.172.0.210:9092
- ports:
- - "9010:9000"
\ No newline at end of file
diff --git a/publish/src/linux-x64/publish/docker/conf/website/nginx.conf b/publish/src/linux-x64/publish/docker/conf/website/nginx.conf
index 3aed0525..b632be11 100644
--- a/publish/src/linux-x64/publish/docker/conf/website/nginx.conf
+++ b/publish/src/linux-x64/publish/docker/conf/website/nginx.conf
@@ -29,7 +29,7 @@ http {
server_name localhost;
location / {
- root /root/nginx/html/desktop;
+ root /root/nginx/html;
if ($http_user_agent ~* "(mobile|android|ipad|iphone|ipod|tablet)") {
root /root/nginx/html/mobile;
}
diff --git a/publish/src/linux-x64/publish/start-dev-temp.cmd b/publish/src/linux-x64/publish/start-dev-temp.cmd
deleted file mode 100644
index e4793fe1..00000000
--- a/publish/src/linux-x64/publish/start-dev-temp.cmd
+++ /dev/null
@@ -1 +0,0 @@
-docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.temp.yml up --remove-orphans -d
\ No newline at end of file