首页 文章 精选 留言 我的

精选列表

搜索[webpack入门],共10000篇文章
优秀的个人博客,低调大师

[雪峰磁针石博客]数据分析工具pandas快速入门教程4-数据汇聚

我们需要的所有信息可能记录在单独的文件和数据帧中。例如,可能有一个公司信息单独表和股票价格表,数据被分成独立的表格以减少冗余信息。 连接 添加行 4-1.py import pandas as pd df1 = pd.read_csv('data/concat_1.csv') df2 = pd.read_csv('data/concat_2.csv') df3 = pd.read_csv('data/concat_3.csv') print(df1) print(df2) print(df3) row_concat = pd.concat([df1, df2, df3]) print(row_concat) print(row_concat.iloc[3, ]) new_row_series = pd.Series(['n1', 'n2', 'n3', 'n4']) print(pd.concat([df1, new_row_series])) new_row_df = pd.DataFrame([['n1', 'n2', 'n3', 'n4']], columns=['A', 'B', 'C', 'D']) print(new_row_df) print(pd.concat([df1, new_row_df])) print(df1.append(df2)) print(df1.append(new_row_df)) data_dict = {'A': 'n1', 'B': 'n2', 'C': 'n3', 'D': 'n4'} print(df1.append(data_dict, ignore_index=True)) row_concat_i = pd.concat([df1, df2, df3], ignore_index=True) print(row_concat_i) 执行结果 $ python3 4-1.py A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 A B C D 0 a4 b4 c4 d4 1 a5 b5 c5 d5 2 a6 b6 c6 d6 3 a7 b7 c7 d7 A B C D 0 a8 b8 c8 d8 1 a9 b9 c9 d9 2 a10 b10 c10 d10 3 a11 b11 c11 d11 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 0 a4 b4 c4 d4 1 a5 b5 c5 d5 2 a6 b6 c6 d6 3 a7 b7 c7 d7 0 a8 b8 c8 d8 1 a9 b9 c9 d9 2 a10 b10 c10 d10 3 a11 b11 c11 d11 A a3 B b3 C c3 D d3 Name: 3, dtype: object A B C D 0 0 a0 b0 c0 d0 NaN 1 a1 b1 c1 d1 NaN 2 a2 b2 c2 d2 NaN 3 a3 b3 c3 d3 NaN 0 NaN NaN NaN NaN n1 1 NaN NaN NaN NaN n2 2 NaN NaN NaN NaN n3 3 NaN NaN NaN NaN n4 A B C D 0 n1 n2 n3 n4 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 0 n1 n2 n3 n4 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 0 a4 b4 c4 d4 1 a5 b5 c5 d5 2 a6 b6 c6 d6 3 a7 b7 c7 d7 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 0 n1 n2 n3 n4 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 4 n1 n2 n3 n4 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 4 a4 b4 c4 d4 5 a5 b5 c5 d5 6 a6 b6 c6 d6 7 a7 b7 c7 d7 8 a8 b8 c8 d8 9 a9 b9 c9 d9 10 a10 b10 c10 d10 11 a11 b11 c11 d11 添加列 4-2.py In [1]: from numpy import NaN, NAN, nan In [2]: print(NaN == True, NaN == False, NaN == 0, NaN == '', sep='|') False|False|False|False In [3]: print(NaN == NaN, NaN == nan, NaN == NAN, nan == NAN, sep='|') False|False|False|False In [4]: import pandas as pd In [5]: print(pd.isnull(NaN), pd.isnull(nan), pd.isnull(NAN), sep='|') True|True|True In [6]: print(pd.notnull(NaN), pd.notnull(99), pd.notnull("https://china-testing.github.io"), sep='|') False|True|True 执行结果 $ python3 4-2.py A B C D A B C D A B C D 0 a0 b0 c0 d0 a4 b4 c4 d4 a8 b8 c8 d8 1 a1 b1 c1 d1 a5 b5 c5 d5 a9 b9 c9 d9 2 a2 b2 c2 d2 a6 b6 c6 d6 a10 b10 c10 d10 3 a3 b3 c3 d3 a7 b7 c7 d7 a11 b11 c11 d11 A A A 0 a0 a4 a8 1 a1 a5 a9 2 a2 a6 a10 3 a3 a7 a11 A B C D A B C D A B C D new_col_list 0 a0 b0 c0 d0 a4 b4 c4 d4 a8 b8 c8 d8 n1 1 a1 b1 c1 d1 a5 b5 c5 d5 a9 b9 c9 d9 n2 2 a2 b2 c2 d2 a6 b6 c6 d6 a10 b10 c10 d10 n3 3 a3 b3 c3 d3 a7 b7 c7 d7 a11 b11 c11 d11 n4 A B C D A B C D A B C D new_col_list \ 0 a0 b0 c0 d0 a4 b4 c4 d4 a8 b8 c8 d8 n1 1 a1 b1 c1 d1 a5 b5 c5 d5 a9 b9 c9 d9 n2 2 a2 b2 c2 d2 a6 b6 c6 d6 a10 b10 c10 d10 n3 3 a3 b3 c3 d3 a7 b7 c7 d7 a11 b11 c11 d11 n4 new_col_series 0 n1 1 n2 2 n3 3 n4 0 1 2 3 4 5 6 7 8 9 10 11 0 a0 b0 c0 d0 a4 b4 c4 d4 a8 b8 c8 d8 1 a1 b1 c1 d1 a5 b5 c5 d5 a9 b9 c9 d9 2 a2 b2 c2 d2 a6 b6 c6 d6 a10 b10 c10 d10 3 a3 b3 c3 d3 a7 b7 c7 d7 a11 b11 c11 d11 合并不同区间 4-3.py import pandas as pd df1 = pd.read_csv('data/concat_1.csv') df2 = pd.read_csv('data/concat_2.csv') df3 = pd.read_csv('data/concat_3.csv') df1.columns = ['A', 'B', 'C', 'D'] df2.columns = ['E', 'F', 'G', 'H'] df3.columns = ['A', 'C', 'F', 'H'] print(df1) print(df2) print(df3) row_concat = pd.concat([df1, df2, df3]) print(row_concat) print(pd.concat([df1, df2, df3], join='inner')) print(pd.concat([df1,df3], ignore_index=False, join='inner')) df1.index = [0, 1, 2, 3] df2.index = [4, 5, 6, 7] df3.index = [0, 2, 5, 7] print(df1) print(df2) print(df3) col_concat = pd.concat([df1, df2, df3], axis=1) print(col_concat) print(pd.concat([df1, df3], axis=1, join='inner')) 执行结果 $ python3 4-3.py A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 E F G H 0 a4 b4 c4 d4 1 a5 b5 c5 d5 2 a6 b6 c6 d6 3 a7 b7 c7 d7 A C F H 0 a8 b8 c8 d8 1 a9 b9 c9 d9 2 a10 b10 c10 d10 3 a11 b11 c11 d11 A B C D E F G H 0 a0 b0 c0 d0 NaN NaN NaN NaN 1 a1 b1 c1 d1 NaN NaN NaN NaN 2 a2 b2 c2 d2 NaN NaN NaN NaN 3 a3 b3 c3 d3 NaN NaN NaN NaN 0 NaN NaN NaN NaN a4 b4 c4 d4 1 NaN NaN NaN NaN a5 b5 c5 d5 2 NaN NaN NaN NaN a6 b6 c6 d6 3 NaN NaN NaN NaN a7 b7 c7 d7 0 a8 NaN b8 NaN NaN c8 NaN d8 1 a9 NaN b9 NaN NaN c9 NaN d9 2 a10 NaN b10 NaN NaN c10 NaN d10 3 a11 NaN b11 NaN NaN c11 NaN d11 Empty DataFrame Columns: [] Index: [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3] A C 0 a0 c0 1 a1 c1 2 a2 c2 3 a3 c3 0 a8 b8 1 a9 b9 2 a10 b10 3 a11 b11 A B C D 0 a0 b0 c0 d0 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 E F G H 4 a4 b4 c4 d4 5 a5 b5 c5 d5 6 a6 b6 c6 d6 7 a7 b7 c7 d7 A C F H 0 a8 b8 c8 d8 2 a9 b9 c9 d9 5 a10 b10 c10 d10 7 a11 b11 c11 d11 A B C D E F G H A C F H 0 a0 b0 c0 d0 NaN NaN NaN NaN a8 b8 c8 d8 1 a1 b1 c1 d1 NaN NaN NaN NaN NaN NaN NaN NaN 2 a2 b2 c2 d2 NaN NaN NaN NaN a9 b9 c9 d9 3 a3 b3 c3 d3 NaN NaN NaN NaN NaN NaN NaN NaN 4 NaN NaN NaN NaN a4 b4 c4 d4 NaN NaN NaN NaN 5 NaN NaN NaN NaN a5 b5 c5 d5 a10 b10 c10 d10 6 NaN NaN NaN NaN a6 b6 c6 d6 NaN NaN NaN NaN 7 NaN NaN NaN NaN a7 b7 c7 d7 a11 b11 c11 d11 A B C D A C F H 0 a0 b0 c0 d0 a8 b8 c8 d8 2 a2 b2 c2 d2 a9 b9 c9 d9 合并多个数据集 4-4.py import pandas as pd person = pd.read_csv('data/survey_person.csv') site = pd.read_csv('data/survey_site.csv') survey = pd.read_csv('data/survey_survey.csv') visited = pd.read_csv('data/survey_visited.csv') print(person) print(site) print(survey) print(visited) visited_subset = visited.iloc[[0, 2, 6], ] o2o_merge = site.merge(visited_subset, left_on='name', right_on='site') print(o2o_merge) m2o_merge = site.merge(visited, left_on='name', right_on='site') print(m2o_merge) ps = person.merge(survey, left_on='ident', right_on='person') vs = visited.merge(survey, left_on='ident', right_on='taken') print(ps) print(vs) 执行结果 $ python3 4-4.py ident personal family 0 dyer William Dyer 1 pb Frank Pabodie 2 lake Anderson Lake 3 roe Valentina Roerich 4 danforth Frank Danforth name lat long 0 DR-1 -49.85 -128.57 1 DR-3 -47.15 -126.72 2 MSK-4 -48.87 -123.40 taken person quant reading 0 619 dyer rad 9.82 1 619 dyer sal 0.13 2 622 dyer rad 7.80 3 622 dyer sal 0.09 4 734 pb rad 8.41 5 734 lake sal 0.05 6 734 pb temp -21.50 7 735 pb rad 7.22 8 735 NaN sal 0.06 9 735 NaN temp -26.00 10 751 pb rad 4.35 11 751 pb temp -18.50 12 751 lake sal 0.10 13 752 lake rad 2.19 14 752 lake sal 0.09 15 752 lake temp -16.00 16 752 roe sal 41.60 17 837 lake rad 1.46 18 837 lake sal 0.21 19 837 roe sal 22.50 20 844 roe rad 11.25 ident site dated 0 619 DR-1 1927-02-08 1 622 DR-1 1927-02-10 2 734 DR-3 1939-01-07 3 735 DR-3 1930-01-12 4 751 DR-3 1930-02-26 5 752 DR-3 NaN 6 837 MSK-4 1932-01-14 7 844 DR-1 1932-03-22 name lat long ident site dated 0 DR-1 -49.85 -128.57 619 DR-1 1927-02-08 1 DR-3 -47.15 -126.72 734 DR-3 1939-01-07 2 MSK-4 -48.87 -123.40 837 MSK-4 1932-01-14 name lat long ident site dated 0 DR-1 -49.85 -128.57 619 DR-1 1927-02-08 1 DR-1 -49.85 -128.57 622 DR-1 1927-02-10 2 DR-1 -49.85 -128.57 844 DR-1 1932-03-22 3 DR-3 -47.15 -126.72 734 DR-3 1939-01-07 4 DR-3 -47.15 -126.72 735 DR-3 1930-01-12 5 DR-3 -47.15 -126.72 751 DR-3 1930-02-26 6 DR-3 -47.15 -126.72 752 DR-3 NaN 7 MSK-4 -48.87 -123.40 837 MSK-4 1932-01-14 ident personal family taken person quant reading 0 dyer William Dyer 619 dyer rad 9.82 1 dyer William Dyer 619 dyer sal 0.13 2 dyer William Dyer 622 dyer rad 7.80 3 dyer William Dyer 622 dyer sal 0.09 4 pb Frank Pabodie 734 pb rad 8.41 5 pb Frank Pabodie 734 pb temp -21.50 6 pb Frank Pabodie 735 pb rad 7.22 7 pb Frank Pabodie 751 pb rad 4.35 8 pb Frank Pabodie 751 pb temp -18.50 9 lake Anderson Lake 734 lake sal 0.05 10 lake Anderson Lake 751 lake sal 0.10 11 lake Anderson Lake 752 lake rad 2.19 12 lake Anderson Lake 752 lake sal 0.09 13 lake Anderson Lake 752 lake temp -16.00 14 lake Anderson Lake 837 lake rad 1.46 15 lake Anderson Lake 837 lake sal 0.21 16 roe Valentina Roerich 752 roe sal 41.60 17 roe Valentina Roerich 837 roe sal 22.50 18 roe Valentina Roerich 844 roe rad 11.25 ident site dated taken person quant reading 0 619 DR-1 1927-02-08 619 dyer rad 9.82 1 619 DR-1 1927-02-08 619 dyer sal 0.13 2 622 DR-1 1927-02-10 622 dyer rad 7.80 3 622 DR-1 1927-02-10 622 dyer sal 0.09 4 734 DR-3 1939-01-07 734 pb rad 8.41 5 734 DR-3 1939-01-07 734 lake sal 0.05 6 734 DR-3 1939-01-07 734 pb temp -21.50 7 735 DR-3 1930-01-12 735 pb rad 7.22 8 735 DR-3 1930-01-12 735 NaN sal 0.06 9 735 DR-3 1930-01-12 735 NaN temp -26.00 10 751 DR-3 1930-02-26 751 pb rad 4.35 11 751 DR-3 1930-02-26 751 pb temp -18.50 12 751 DR-3 1930-02-26 751 lake sal 0.10 13 752 DR-3 NaN 752 lake rad 2.19 14 752 DR-3 NaN 752 lake sal 0.09 15 752 DR-3 NaN 752 lake temp -16.00 16 752 DR-3 NaN 752 roe sal 41.60 17 837 MSK-4 1932-01-14 837 lake rad 1.46 18 837 MSK-4 1932-01-14 837 lake sal 0.21 19 837 MSK-4 1932-01-14 837 roe sal 22.50 20 844 DR-1 1932-03-22 844 roe rad 11.25 参考资料 技术支持qq群144081101 591302926 567351477 钉钉免费群21745728 本文最新版本地址 本文涉及的python测试开发库 谢谢点赞! 本文相关海量书籍下载 源码下载 本文英文版书籍下载

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

区块链入门、进阶、行业专家观点!1000篇好文帮你破解区块链密码!(下篇)

随着区块链概念理论的不断成熟以及强劲技术的不断深耕,区块链已经成为投资圈中备受关注的热点,从区块链1.0时代落地数字货币比特币、莱特币等,打开了区块链通向新弯道的高速路口,到区块链2.0时代开始通过智能合约来解决货币支付难题,再到3.0时代区块链尝试向各传统行业发力,标志着区块链逐渐由萌芽状态走向实际满足人们渴求状态。 互联网时代已经深入整个世界,区块链问世时,人们感受到的是另一个全新时代脚步正在靠近,春节期间引发社区热点的“三点钟无眠区块链”给了2018年开场红,区块链正要迎来它的新元年。 云栖社区特整理出1000篇关于区块链的文章分享给大家,从技术原理到应用实践,应有尽有。以下为下篇: 区块链安全如何保证?公有私有哪家强? 区块链101:什么是SegWit(隔离见证)? 区块链和中央银行 - 我们学到了什么? 感谢区块链,分权和数据安全

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

区块链入门、进阶、行业专家观点!1000篇好文帮你破解区块链密码!(上篇)

随着区块链概念理论的不断成熟以及强劲技术的不断深耕,区块链已经成为投资圈中备受关注的热点,从区块链1.0时代落地数字货币比特币、莱特币等,打开了区块链通向新弯道的高速路口,到区块链2.0时代开始通过智能合约来解决货币支付难题,再到3.0时代区块链尝试向各传统行业发力,标志着区块链逐渐由萌芽状态走向实际满足人们渴求状态。 互联网时代已经深入整个世界,区块链问世时,人们感受到的是另一个全新时代脚步正在靠近,春节期间引发社区热点的“三点钟无眠区块链”给了2018年开场红,区块链正要迎来它的新元年。 云栖社区特整理出1000篇关于区块链的文章分享给大家,从技术原理到应用实践,应有尽有。以下为上篇: 一文教你读懂区块链 5分钟创建并玩转属于自己的区块链 区块链上的中国?2018见分晓 【观点】以太坊创始人认为区块链技术将在几年内抢走Visa的业务 区块链

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

【通信中间件】电信级解决方案中间件ICE编程入门指南

0.ICE介绍:ICE(Internet Communications Engine)是ZeroC提供的一款高性能的中间件,基于ICE可以实现电信级的解决方案。个人理解与COBRA貌似基本上是一个作用的东西,由于项目上要用到,早上简单实用了一下,还是很方便的。 1.开发流程: 编写ICE接口文件=>选择开发语言,生成相关类和接口=>开发Server端=>开发Client端=>部署Server端=>运行Client 2.安装: 环境:Ubuntu 9.10 $sudo apt-get install zeroc-* 3.实例:编写一个名为shareiceserver 的模块,里面有一个名为Sonics的接口 1)编写ICE文件: module shareiceserver { interface Sonics{ int authenUser(string userID, string password); bool isOrdered(string userID, string appID);// SONICS查询某用户是否订购某业务:返回值bool bool checkBalanceByName(string userID, double balance); string getHomeSCSByUserID(string userID);//SONICS查询某用户归属SCS信息:返回值 }; }; //shareiceserver 在这个模块中,我们定义了一个接口,请注意这个接口与Java中的接口并不是一个概念,在后边自动生成代码时会生成一系列类和接口。 将这个文件保存为shareiceserver.ice 2)选择开发语言: 我们在此选择Java作为C-S两端的语言,当然,由于ICE的封装,在两端分别使用哪种语言其实并没有关系。接着,我们将这个接口文件生成Java proxies 和skeletons,这两者的具体概念请参看我的Blog的另一篇文字:《分布计算环境学习笔记2——分布式系统中的面向对象技术》,其中关于IDL语言的对应关系与此道理相同。 生成接口和类文件 slice2java shareiceserver.ice 此时会产生一个叫做shareiceserver的文件夹: sam@sam-desktop:~/ICE/shareiceserver$ ls _SonicsDelD.java _SonicsDelM.java SonicsHolder.java _SonicsOperations.java SonicsPrxHelper.java SonicsPrx.java _SonicsDel.java _SonicsDisp.java Sonics.java _SonicsOperationsNC.java SonicsPrxHolder.java 3)开发Server端(传统方法) a.添加定义的方法的具体实现:SonicsI.java public class SonicsI extends shareiceserver._SonicsDisp{ public int authenUser(String userID, String password, Ice.Current current) { return 0; } public boolean checkBalanceByName(String userID, double balance, Ice.Current current) { return true; } public String getHomeSCSByUserID(String userID ,Ice.Current current) { return userID+":192.168.0.1"; } public boolean isOrdered(String userID, String appID, Ice.Current current) { return true; } } 继承_SonicsDisp创建servant类SonicsI(一般我们在接口的名字后边加上I表示servant类),_SonicsDisp是自动生成的,这是个抽象类,包含了我们要实现的方法的原型(只是每一个方法都加入了一个Ice.Current类型的参数)。我们这里只是示意性的对方法进行了实现,没有什么具体的逻辑。 .b.编写Server端主程序代码:Server.java public class Server { public static void main(String[] args) { int status = 0; Ice.Communicator ic = null; try { ic = Ice.Util.initialize(args);//初始化Ice,返回一个Ice::Communicator引用作为Ice的运行操作句柄。 Ice.ObjectAdapter adapter//在此Ice环境下创建一个对象适配器(名为SimpleSonics),default为使用默认协议TCP/IP,并使用端口10000。初始化至此完成。 = ic.createObjectAdapterWithEndpoints( "SimpleSonics", "default -p 10000"); Ice.Object object = new SonicsI();//创建一个servant实例。 adapter.add( object, Ice.Util.stringToIdentity("SimpleSonics"));//将这个servant实例加入对象适配器,并且指明名称。 adapter.activate();//激活适配器 ic.waitForShutdown();//这个调用将该线程挂起直到Server终止。在这里,我们简单使用命令行终止的方式。 } catch (Ice.LocalException e) { e.printStackTrace(); status = 1; } catch (Exception e) { System.err.println(e.getMessage()); status = 1; } if (ic != null) { // Clean up // try { ic.destroy();//在程序退出之前要对Ice整个环境进行销毁。 } catch (Exception e) { System.err.println(e.getMessage()); status = 1; } } System.exit(status); } } 在编写Server端程序时,我们要对ICE和以及程序逻辑运行时可能抛出的异常做处理,然后再注册启动Server端。 编译:(在ubuntu环境下Ice.jar的位置如下,其他环境需要修改) $mkdir classes $javac Server.java SonicsI.java shareiceserver/*.java -classpath /usr/share/java/Ice.jar -d classes 4)编写Client端主程序代码:Client.java public class Client { public static void main(String[] args) { int status = 0; Ice.Communicator ic = null; try { ic = Ice.Util.initialize(args);//初始化Ice环境 Ice.ObjectPrx base = ic.stringToProxy(//添加一个代理,设定名字、协议、端口。返回接口与类的继承树的根部 "SimpleSonics:default -p 10000"); shareiceserver.SonicsPrx sonicser =shareiceserver.SonicsPrxHelper.checkedCast(base);//沿着这个继承树寻找Sonics if (sonicser== null)//若无法找到则返回null,至此准备工作完成。 throw new Error("Invalid proxy"); System.out.println(sonicser.getHomeSCSByUserID("001"));//具体方法调用 } catch (Ice.LocalException e) { e.printStackTrace(); status = 1; } catch (Exception e) { System.err.println(e.getMessage()); status = 1; } if (ic != null) { // Clean up // try { ic.destroy();//销毁Ice环境 } catch (Exception e) { System.err.println(e.getMessage()); status = 1; } } System.exit(status); } } 编译: javac Client.java shareiceserver/*.java -classpath /usr/share/java/Ice.jar -d classes 5)部署运行: 环境配置:(否则出现NoClassDefFoundError: Ice/LocalException异常) export CLASSPATH=$CLASSPATH:./classes:/usr/share/java/Ice.jar Server端运行: ~/ICE/classes$ java Server & Client端运行: ~/ICE/classes$ java Client 运行结果: 001:192.168.0.1 4.使用Ice.Application创建Server和Client端 在官方文档中,推荐在只创建一个communicator时使用Ice.Application类进行程序编写(http://www.zeroc.com/doc/Ice-3.2b/manual/Javas.13.3.html)。 Server端:Server1.java public class Server1 extends Ice.Application { public int run(String[] args) { Ice.Communicator ic = communicator(); Ice.ObjectAdapter adapter = ic.createObjectAdapterWithEndpoints( "SimpleSonics", "default -p 10000"); Ice.Object object = new SonicsI(); adapter.add( object, Ice.Util.stringToIdentity("SimpleSonics")); adapter.activate(); ic.waitForShutdown(); return 0; } public static void main(String[] args) { Server1 app = new Server1(); int status = app.main("Server1", args); System.exit(status); } } Client端:Client1.java public class Client1 extends Ice.Application { public int run(String[] args) { Ice.Communicator ic = Ice.Util.initialize(args); Ice.ObjectPrx base = ic.stringToProxy( "SimpleSonics:default -p 10000"); shareiceserver.SonicsPrx sonicser =shareiceserver.SonicsPrxHelper.checkedCast(base); if (sonicser== null) throw new Error("Invalid proxy"); System.out.println(sonicser.getHomeSCSByUserID("001")); return 0; } public static void main(String[] args) { Client1 app = new Client1(); int status = app.main("Client1", args); System.exit(status); } } 使用这个类的好处是程序清晰,并且自动在其中提供了信号处理、配置等功能。编译方法与上相同。 5.关闭信号的捕捉 在Ice.Application中,在JVM关闭之前程序默认调用destroyOnInterrupt这个回调函数完成一些clean和hint的工作: if(interrupted()) System.err.println(appName()+ ": terminating"); return 0; 但是这个默认的回调函数在主程序阻塞时(比如主程序接收键盘输入时)不会被调用,为了克服这一特点,我们可以自己注册一个回调函数: public class Server extends Ice.Application { class ShutdownHook extends Thread { public voidrun() { try { communicator().destroy(); } catch(Ice.LocalException ex) { ex.printStackTrace(); } } }  public intrun(String[] args) { setInterruptHook(new ShutdownHook());  // ... } } 本文转自gnuhpc博客园博客,原文链接:http://www.cnblogs.com/gnuhpc/archive/2012/12/17/2822231.html,如需转载请自行联系原作者

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

产品经理教你玩转阿里云负载均衡SLB系列(一):快速入门--什么是负载均衡

负载均衡是一种技术,从字面意义上理解,就是让负载(变得)均衡,负载是什么呢?可以理解为工作量、工作强度。用日常生活中的例子来打比方,一群建筑工人,盖一幢楼房,有搬砖的,有和水泥的,有砌墙的,有刷油漆的,同时每个工人的劳动能力还各有差别,如果让这些工作自组织的干起活来,可能有的人忙到累死,而有的人闲的无聊 ,因此不论大小工地上,都会存在监工、项目经理、包工头等这样的角色,他们会统观全局,识别每个工人的工作强度,合理分配任务,保证建筑活动的正常开展,很大程度上起到了的负载均衡的作用, 这就是负载均衡在生活中的例子。 接下来我们来看看云计算中所说的负载均衡是什么。 阿里云负载均(Server Load Balancer)是对多台云服务器进行流量分发的负载均衡服务。负载均衡可以通过流量分发扩展应用系统对外的服务能力,通过消除单点故障提升应用系

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

OpenStack入门修炼之Cinder服务-->安装并配置一个本地存储节点(18)

怎样为块存储服务安装并配置存储节点。为简单起见,这里配置一个有一个空的本地块存储设备的存储节点。这个向导用的是 /dev/sdb,此处选用linux-node1节点作为存储节点,需要在vmware中添加一块磁盘。 1.安装支持的工具包 安装 LVM 包: [root@linux-node1 ~]# yum install -y lvm2 启动LVM的metadata服务并且设置该服务随系统启动: [root@linux-node1 ~]# systemctl enable lvm2-lvmetad.service [root@linux-node1 ~]# systemctl start lvm2-lvmetad.service 2.创建LVM物理卷/dev/sdb和卷组 cinder-volumes [root@linux-node1 ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created. [root@linux-node1 ~]# vgcreate cinder-volumes /dev/sdb Volume group "cinder-volumes" successfully created 3.修改配置/etc/lvm/lvm.conf 由于存储节点在操作系统磁盘上使用了 LVM,必需添加相关的设备到过滤器中。例如,如果 /dev/sda 设备包含操作系统: [root@linux-node1 ~]# vim /etc/lvm/lvm.conf devices { filter = [ "a/sda/", "a/sdb/", "r/.*/"] 4.安装并配置组件 [root@linux-node1 ~]# yum install -y openstack-cinder targetcli python-keystone [root@linux-node1 ~]# vim /etc/cinder/cinder.conf 在文末增加 [lvm] <==配置LVM后端,包括LVM驱动,cinder-volume卷组,iscsi协议以及服务 volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver volume_group = cinder-volumes iscsi_protocol = iscsi iscsi_helper = lioadm [DEFAULT] enabled_backends = lvm <==启用LVM后端 iscsi_ip_address = 192.168.56.11 <==配置iscsi监听地址 glance_api_servers = http://192.168.56.11:9292 <==配置镜像服务API的位置 5.完成安装,启动cinder-volume服务,并查看 [root@linux-node1 ~]# systemctl enable openstack-cinder-volume.service target.service [root@linux-node1 ~]# systemctl start openstack-cinder-volume.service target.service [root@linux-node1 ~]# source admin-openstack [root@linux-node1 ~]# openstack volume service list +------------------+-----------------+------+---------+-------+----------------------------+ | Binary | Host | Zone | Status | State | Updated At | +------------------+-----------------+------+---------+-------+----------------------------+ | cinder-scheduler | linux-node1 | nova | enabled | up | 2017-12-08T09:24:55.000000 | | cinder-volume | linux-node1@lvm | nova | enabled | up | 2017-12-08T09:25:01.000000 | +------------------+-----------------+------+---------+-------+----------------------------+ 6.创建云硬盘并挂载 (1)打开dashboard,进入卷,点击"创建卷"安装并配置一个本地存储节点(18)" style="margin:0px 0px 15px;padding:0px;border:none;" data-original="http://i2.51cto.com/images/blog/201712/12/ae7ff2993b33d62b2ec6e449102802d1.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk="> 安装并配置一个本地存储节点(18)" style="margin:0px 0px 15px;padding:0px;border:none;" data-original="http://i2.51cto.com/images/blog/201712/12/ddb383e088471c3b735fd61d7ad25035.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk="> (2)将卷加入到云主机中,"编辑卷"-->"管理连接"-->"链接云主机"安装并配置一个本地存储节点(18)" style="margin:0px 0px 15px;padding:0px;border:none;" data-original="http://i2.51cto.com/images/blog/201712/12/9611d58db545ab5af0de54c4867c64e9.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk="> (3)进入云主机进行查看磁盘挂载情况 fdisk -l,成功挂载1G的云硬盘,对该磁盘进行格式化,并写入数据安装并配置一个本地存储节点(18)" style="margin:0px 0px 15px;padding:0px;border:none;" data-original="http://i2.51cto.com/images/blog/201712/12/010c09b1777ebb00da38da6385a7b90c.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk="> 安装并配置一个本地存储节点(18)" style="margin:0px 0px 15px;padding:0px;border:none;" data-original="http://i2.51cto.com/images/blog/201712/12/4d977db376d991c1fe5df07582ce3544.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk="> tips:当有多个节点需要挂载该云盘,需要将该磁盘进行umount,再到"管理连接"-->"分离卷"。分离卷时,该磁盘数据不会丢失。挂到其他云主机时,不再需要格式化,直接可挂载。 存储节点可选用的存储类型 1.使用本地硬盘 2.系统使用本地硬盘+云硬盘(数据盘) ISCSI NFS GlusterFS Ceph 本文转自 IT_外卖小哥 51CTO博客,原文链接:http://blog.51cto.com/jinlong/2049797

资源下载

更多资源
Mario

Mario

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

腾讯云软件源

腾讯云软件源

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

Spring

Spring

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

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

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