首页 文章 精选 留言 我的

精选列表

搜索[Java实现],共10000篇文章
优秀的个人博客,低调大师

Pyodide —— 在浏览器端实现 Python 全栈科学计算

Pyodide 由编译成 WebAssembly 的 CPython 3.8 解释器组成,允许 Python 在网页浏览器中运行。 Pyodide 可以安装来自 PyPi 的任何 Python 包。Pyodide 还包括一个外部函数接口,可以将 Python 包暴露给 JavaScript,并将浏览器 UI,包括 DOM,暴露给 Python。该项目还使许多 Python 科学包,包括 NumPy、Pandas、Matplotlib、SciPy 和 Scikit-learn,就可以在浏览器中运行。

优秀的个人博客,低调大师

windows下jenkins+git+maven+tomcat实现自动化部署

Jenkins自动化部署: 几条具体的思路:1、开发人员将产品开发完后提交到集成代码库(git/svn)托管 2、通过Jenkins创建服务项目 3、从git/svn上拉取最新的master代码分支 4、编译代码并打包成war包 5、通过脚本发布到对应的容器中(tomcat/weblogic),并启动项目 这里主要就是这几项。集成maven、git,经过一些github、tomcat的配置,一键操作一键完成项目从github发布到阿里云服务器。Jenkins调用git的命令,拉github的项目,项目经过maven打包war文件,copy到容器中并启动服务 ---------------------------------------------------------------------------安装jenkins------------------------------------------------------------------------------------------------ 1.进入jenkins官网 https://www.jenkins.io/,下载windows版(一般下载官网最新的稳定版本---LTS版本) 下载后进行安装,设置好端口(例如: 8001),选择官方默认配置的插件安装后即可(详细的安装教程网上一大堆就不写了) ---------------------------------------------------------------------------配置jenkins------------------------------------------------------------------------------------------------ 1.打开 Manage Jenkins---->Manage plugins 插件管理 2.在可选插件中查找官网maven插件,下载 Maven Integration plugin 3.下载完毕后重启jenkins, 4.全局配置 5. 新建一个任务 windows批处理脚本如下: @echo off E: cd apache-tomcat-8.5.33\webapps if exist "E:\apache-tomcat-8.5.33\webapps\clearBadDataDemo.war" del "E:\tomcat\apache-tomcat-8.0.47\webapps\clearBadDataDemo.war" copy "C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\clearData\target\clearBadDataDemo.war" "E:\apache-tomcat-8.5.33\webapps\clearBadDataDemo.war" if exist "E:\apache-tomcat-8.5.33\webapps\clearBadDataDemo\" rd /s /q "E:\apache-tomcat-8.5.33\webapps\clearBadDataDemo\" cd / cd apache-tomcat-8.5.33\bin set BUILD_ID=dontKillMe call startup.bat echo good bye jenkins在任务执行完毕后会自动杀死主进程导致项目跟着一起关闭,控制台会报错 Process leaked file descriptors. See https://jenkins.io/redirect/troubleshooting/process-leaked-file-descriptors for more information 两种解决方案: 1:在脚本启动tomcat前加上set BUILD_ID=dontKillMe 2:在全局变量中设置 然后启动任务 虽然现在依旧会有警告会杀死tomcat进程,但是已经启动完毕 现在虽然可以访问了,但是tomcat是在后台运行的 ,我们需要配置一下将tomcat已控制台的形式输出,方便管理 配置一下任务节点 然后启动build 即可弹出tomcat执行窗口了

优秀的个人博客,低调大师

使用 Android 模拟器容器来实现持续集成测试

如今,借助我们预先构建好的 Android 模拟器容器,在持续集成和交付系统 (CI/CD) 上设置以及运行 Android 模拟器比以往任何时候都容易。这些容器可以让您轻松找到并运行正确版本的模拟器,而不必再因为依赖管理而头疼。其同时也让持续集成和交付系统增加自动化测试变得更为简单,而且不用担心维护大量实体设备所产生的花销。 去年的早些时候,我们发布了 Android 模拟器下载以及 Docker 镜像生成的脚本 来帮助开发者部署和调试远程模拟器。这些脚本简化了寻找正确版本的系统镜像、管理系统依赖以及运行 Android 模拟器的流程。 如今,我们决定更进一步,来实验性地为每一个重大模拟器更新发布提供预先构建好的 Android 模拟器容器。这些容器不再需要您手动地运行生成器,既节省时间,也降低了复杂度。不用担心,这些预先构建好的容器依然支持用 Docker 脚本构建的容器的所有功能,比如 adb 和 web 可访问性。 想要运行这些容器,Linux KVM 是必需的,可以通过在裸机或者支持嵌套虚拟化的虚拟机上运行来启动 Linux KVM。选择哪种方式取决于您的云计算提供商,请参阅我们的 文档 获取建议。 以下脚本说明了如何将 Android 模拟器容器集成到您的系统中,并且使用其运行测试。 #!/bin/bash # 这个是我们将要运行的远程镜像 # 如果需要,Docker 会帮我们获取该镜像 DOCKER_IMAGE=us-docker.pkg.dev/android-emulator-268719/images/r-google-x64:30.0.23 # 这个是转发端口。最好选用高位端口,这样就不会干扰到 adb 扫描模拟器。 PORT=15555 # 这里会在后台启动容器 container_id=$(docker run -d \ -e "ADBKEY=$(cat ~/.android/adbkey)" --device /dev/kvm --publish \ 8554:8554/tcp --publish $PORT:5555/tcp \ $DOCKER_IMAGE) echo "The container is running with id: $container_id" # 注意,您可能会碰到如下信息: # failed to connect to localhost: 15555 # 这只不过表明容器还没有准备好 echo "Connecting to forwarded adb port." adb connect localhost:$PORT # 我们不得不等到 `docker ps` 显示为正常。 # 这一过程可能需要一段时间因为模拟器需要完全启动! echo "Waiting until the device is ready" adb wait-for-device # 现在这个设备正在启动,或者接近启动完成。 # 我们只等 sys.boot_completed 的值被设置为1。 while [ "`adb shell getprop sys.boot_completed | tr -d '\r' `" != "1" ] ; do echo "Still waiting for boot.." sleep 1; done # 现在你可以正常地使用模拟器了,举个例子: # ./gradlew installDebug # ./gradlew connectedAndroidTest # 等等 echo "The device is ready" echo "Run the following command to stop the container:" echo "docker stop ${container_id}" Android 模拟器容器的镜像拉取、运行以及端口转发的示例脚本 想要了解更多关于 Android 模拟器容器的信息,请查阅 README。这是我们首次提供预先构建好的模拟器容器,所以如果您在使用的过程中发现任何问题或功能请求,请通过 issue tracker 告知我们。

优秀的个人博客,低调大师

简单4步,利用Prometheus Operator实现自定义指标监控

本文来自Rancher Labs 在过去的文章中,我们花了相当大的篇幅来聊关于监控的话题。这是因为当你正在管理Kubernetes集群时,一切都会以极快的速度发生变化。因此有一个工具来监控集群的健康状态和资源指标极为重要。 在Rancher 2.5中,我们引入了基于Prometheus Operator的新版监控,它可以提供Prometheus以及相关监控组件的原生Kubernetes部署和管理。Prometheus Operator可以让你监控集群节点、Kubernetes组件和应用程序工作负载的状态和进程。同时,它还能够通过Prometheus收集的指标来定义告警并且创建自定义仪表盘,通过Grafana可以轻松地可视化收集到的指标。你可以访问下列链接获取更多关于新版监控组件的细节: https://rancher.com/docs/rancher/v2.x/en/monitoring-alerting/v2.5/ 新版本的监控也采用prometheus-adapter,开发人员可以利用其基于自定义指标和HPA扩展他们的工作负载。 在本文中,我们将探索如何利用Prometheus Operator来抓取自定义指标并利用这些指标进行高级工作负载管理。 安装Prometheus 在Rancher 2.5中安装Prometheus极为简单。仅需访问Cluster Explorer -> Apps并安装rancher-monitoring即可。 你需要了解以下默认设置: prometheus-adapter将会作为chart安装的一部分启用 ServiceMonitorNamespaceSelector 留为空,允许 Prometheus 在所有命名空间中收集 ServiceMonitors 安装完成后,我们可以从Cluster Explorer访问监控组件。 部署工作负载 现在让我们部署一个从应用层暴露自定义指标的示例工作负载。该工作负载暴露了一个简单的应用程序,该应用程序已经使用Prometheus client_golang库进行了检测,并在/metric端点上提供了一些自定义指标。 它有两个指标: http_requests_total http_request_duration_seconds 以下manifest部署了工作负载、相关服务以及访问该工作负载的ingress: apiVersion: apps/v1 kind: Deployment metadata: labels: app.kubernetes.io/name: prometheus-example-app name: prometheus-example-app spec: replicas: 1 selector: matchLabels: app.kubernetes.io/name: prometheus-example-app template: metadata: labels: app.kubernetes.io/name: prometheus-example-app spec: containers: - name: prometheus-example-app image: gmehta3/demo-app:metrics ports: - name: web containerPort: 8080 --- apiVersion: v1 kind: Service metadata: name: prometheus-example-app labels: app.kubernetes.io/name: prometheus-example-app spec: selector: app.kubernetes.io/name: prometheus-example-app ports: - protocol: TCP port: 8080 targetPort: 8080 name: web --- apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: prometheus-example-app spec: rules: - host: hpa.demo http: paths: - path: / backend: serviceName: prometheus-example-app servicePort: 8080 部署ServiceMonitor ServiceMonitor是一个自定义资源定义(CRD),可以让我们声明性地定义如何监控一组动态服务。 你可以访问以下链接查看完整的ServiceMonitor规范: https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#servicemonitor 现在,我们来部署ServiceMonitor,Prometheus用它来收集组成prometheus-example-app Kubernetes服务的pod。 kind: ServiceMonitor metadata: name: prometheus-example-app spec: selector: matchLabels: app.kubernetes.io/name: prometheus-example-app endpoints: - port: web 如你所见,现在用户可以在Rancher监控中浏览ServiceMonitor。 不久之后,新的service monitor和服务相关联的pod应该会反映在Prometheus服务发现中。 我们也能够在Prometheus中看到指标。 部署Grafana仪表盘 在Rancher 2.5中,监控可以让用户将Grafana仪表盘存储为cattle-dashboards命名空间中的ConfigMaps。 用户或集群管理员现在可以在这一命名空间中添加更多的仪表盘以扩展Grafana的自定义仪表盘。 Dashboard ConfigMap Example apiVersion: v1 kind: ConfigMap metadata: name: prometheus-example-app-dashboard namespace: cattle-dashboards labels: grafana_dashboard: "1" data: prometheus-example-app.json: | { "annotations": { "list": [ { "builtIn": 1, "datasource": "-- Grafana --", "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" } ] }, "editable": true, "gnetId": null, "graphTooltip": 0, "links": [], "panels": [ { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": null, "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "fill": 1, "fillGradient": 0, "gridPos": { "h": 9, "w": 12, "x": 0, "y": 0 }, "hiddenSeries": false, "id": 2, "legend": { "avg": false, "current": false, "max": false, "min": false, "show": true, "total": false, "values": false }, "lines": true, "linewidth": 1, "nullPointMode": "null", "percentage": false, "pluginVersion": "7.1.5", "pointradius": 2, "points": false, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { "expr": "rate(http_requests_total{code=\"200\",service=\"prometheus-example-app\"}[5m])", "instant": false, "interval": "", "legendFormat": "", "refId": "A" } ], "thresholds": [], "timeFrom": null, "timeRegions": [], "timeShift": null, "title": "http_requests_total_200", "tooltip": { "shared": true, "sort": 0, "value_type": "individual" }, "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true }, { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } }, { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": null, "description": "", "fieldConfig": { "defaults": { "custom": {} }, "overrides": [] }, "fill": 1, "fillGradient": 0, "gridPos": { "h": 8, "w": 12, "x": 0, "y": 9 }, "hiddenSeries": false, "id": 4, "legend": { "avg": false, "current": false, "max": false, "min": false, "show": true, "total": false, "values": false }, "lines": true, "linewidth": 1, "nullPointMode": "null", "percentage": false, "pluginVersion": "7.1.5", "pointradius": 2, "points": false, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { "expr": "rate(http_requests_total{code!=\"200\",service=\"prometheus-example-app\"}[5m])", "interval": "", "legendFormat": "", "refId": "A" } ], "thresholds": [], "timeFrom": null, "timeRegions": [], "timeShift": null, "title": "http_requests_total_not_200", "tooltip": { "shared": true, "sort": 0, "value_type": "individual" }, "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true }, { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } } ], "schemaVersion": 26, "style": "dark", "tags": [], "templating": { "list": [] }, "time": { "from": "now-15m", "to": "now" }, "timepicker": { "refresh_intervals": [ "5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d" ] }, "timezone": "", "title": "prometheus example app", "version": 1 } 现在,用户应该能够在Grafana中访问prometheus example app的仪表盘。 自定义指标的HPA 这一部分假设你已经将prometheus-adapter作为监控的一部分安装完毕了。实际上,在默认情况下,监控安装程序会安装prometheus-adapter。 用户现在可以创建一个HPA spec,如下所示: apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: name: prometheus-example-app-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: prometheus-example-app minReplicas: 1 maxReplicas: 5 metrics: - type: Object object: describedObject: kind: Service name: prometheus-example-app metric: name: http_requests target: averageValue: "5" type: AverageValue 你可以查看以下链接获取关于HPA的更多信息: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/ 我们将使用自定义的http_requests_total指标来执行pod自动伸缩。 现在我们可以生成一个样本负载来查看HPA的运行情况。我可以使用hey进行同样的操作。 hey -c 10 -n 5000 http://hpa.demo 总 结 在本文中,我们探讨了Rancher 2.5中新监控的灵活性。开发人员和集群管理员可以利用该堆栈来监控它们的工作负载,部署可视化,并利用Kubernetes内可用的高级工作负载管理功能。

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

用户登录
用户注册
修改密码
忘记密码